improve scripts add example cfg

master
Kebler Network System Administrator 2022-04-26 18:30:12 -07:00
parent 62b24b6713
commit a108a88a4d
5 changed files with 26 additions and 14 deletions

View File

@ -1,4 +1,4 @@
version: "2.1"
version: "3.8"
services:
code-server:
image: ghcr.io/linuxserver/code-server

View File

@ -3,6 +3,6 @@
# USER=jim
# TZ=America/Los_Angles
# Password=jimshoe
Parent_Folder=/mnt/data
Files=/mnt/data/test-files
Parent_Folder=/data
Files=/data/test-files # will be /data/<name> by default
Port=4321 # should be changed to avoid conflict with other containers

View File

@ -1,23 +1,29 @@
#!/bin/bash
is_p_int() { [ "$1" ] && [ -z "${1//[0-9]}" ] ;}
is_p_int() { [ "$1" ] && [ -z "${1//[0-9]/}" ]; }
declare -A settings
# echo env $1
[[ ! $(getent group docker) ]] && echo no docker group on machine, exiting && exit
[[ ! $1 ]] && echo "no editor set, usage make <editor>" && exit
SDIR=$(cd $(dirname $(readlink -f "$0")) >/dev/null 2>&1 ; pwd -P)
SDIR=$(
cd $(dirname $(readlink -f "$0")) >/dev/null 2>&1
pwd -P
)
ENV_FILE=$SDIR/editors/${1}.cfg
echo getting config file $ENV_FILE
# source any environment for particular site
# shopt -s extglob
# ENV_FILE=$(ls ${FILE}* 2> /dev/null | grep -v '.off$\|.example$\|.tmpl$\|.template$')
[[ -f $ENV_FILE ]] && source $ENV_FILE || echo WARNING no settings file $ENV_FILE, using defaults
PUID=$(id -u $USER 2> /dev/null)
PUID=$(id -u $USER 2>/dev/null)
[[ ! $PUID ]] && echo no user $USER, exiting && exit
[[ ! $(getent group docker | grep ${USER}) ]] && echo $USER not in docker group, exiting && exit
__ce_PUID=${PUID:-$([[ ! $(is_p_int PUID) ]] && echo $(id -u ))}
__ce_PUID=${PUID:-$([[ ! $(is_p_int PUID) ]] && echo $(id -u))}
__ce_PGID=${PGID:-$(getent group docker | cut -d: -f3)}
ename=$(basename "${1%.*}")
ename=${2:-$(basename "${1%.*}")}
__ce_Name=${Name:-$ename-files-editor}
__ce_TZ=${TZ:-"America/Los_Angeles"}
__ce_Password=${Password:-password}
@ -28,4 +34,7 @@ __ce_Config=${Config:-${Parent_Folder}/$ename/config}
mkdir -p ${__ce_Config}
__ce_Port=${Port:-8443}
echo "$( set -o posix ; set | grep __ce_ | sed 's/__ce_//')" > $SDIR/editors/docker.$ename.env
echo "$(
set -o posix
set | grep __ce_ | sed 's/__ce_//'
)" >$SDIR/editors/docker.$1.env

View File

@ -1,5 +1,5 @@
#!/bin/bash
[[ ! $1 ]] && echo "no editor set, usage restart <editor>" && exit
SDIR=$(cd $(dirname $(readlink -f "$0")) >/dev/null 2>&1 ; pwd -P)
source $SDIR/stop $1
source $SDIR/start $1
source $SDIR/stop $editor
source $SDIR/start $editor

7
start
View File

@ -2,5 +2,8 @@
[[ ! $1 ]] && echo "no editor set, usage start <editor>" && exit
SDIR=$(cd $(dirname $(readlink -f "$0")) >/dev/null 2>&1 ; pwd -P)
env_file=$SDIR/editors/docker.${1}.env
[[ ! -f $env_file ]] && $($SDIR/make-env-file $1)
docker-compose --env-file $SDIR/editors/docker.${1}.env up -d
echo $env_file
[[ ! -f "$env_file" ]] && echo file does not exist && $SDIR/make-env-file $1 && echo making env file from cfg
cat $env_file
# -p for separate container instances
docker-compose -p $1 --env-file $env_file up -d