2021-01-15 07:41:34 -08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-04-26 18:30:12 -07:00
|
|
|
is_p_int() { [ "$1" ] && [ -z "${1//[0-9]/}" ]; }
|
2021-01-15 07:41:34 -08:00
|
|
|
|
|
|
|
declare -A settings
|
|
|
|
|
2022-04-26 18:30:12 -07:00
|
|
|
# echo env $1
|
|
|
|
|
2021-01-15 07:41:34 -08:00
|
|
|
[[ ! $(getent group docker) ]] && echo no docker group on machine, exiting && exit
|
|
|
|
[[ ! $1 ]] && echo "no editor set, usage make <editor>" && exit
|
2022-04-26 18:30:12 -07:00
|
|
|
SDIR=$(
|
|
|
|
cd $(dirname $(readlink -f "$0")) >/dev/null 2>&1
|
|
|
|
pwd -P
|
|
|
|
)
|
2021-01-15 07:41:34 -08:00
|
|
|
ENV_FILE=$SDIR/editors/${1}.cfg
|
2022-04-26 18:30:12 -07:00
|
|
|
echo getting config file $ENV_FILE
|
2021-01-15 07:41:34 -08:00
|
|
|
# source any environment for particular site
|
|
|
|
# shopt -s extglob
|
|
|
|
# ENV_FILE=$(ls ${FILE}* 2> /dev/null | grep -v '.off$\|.example$\|.tmpl$\|.template$')
|
2022-04-26 18:30:12 -07:00
|
|
|
[[ -f $ENV_FILE ]] && source $ENV_FILE || echo WARNING no settings file $ENV_FILE, using defaults
|
|
|
|
PUID=$(id -u $USER 2>/dev/null)
|
2021-01-15 07:41:34 -08:00
|
|
|
[[ ! $PUID ]] && echo no user $USER, exiting && exit
|
|
|
|
[[ ! $(getent group docker | grep ${USER}) ]] && echo $USER not in docker group, exiting && exit
|
2022-04-26 18:30:12 -07:00
|
|
|
__ce_PUID=${PUID:-$([[ ! $(is_p_int PUID) ]] && echo $(id -u))}
|
2021-01-15 07:41:34 -08:00
|
|
|
__ce_PGID=${PGID:-$(getent group docker | cut -d: -f3)}
|
2022-04-26 18:30:12 -07:00
|
|
|
ename=${2:-$(basename "${1%.*}")}
|
2021-01-15 07:41:34 -08:00
|
|
|
__ce_Name=${Name:-$ename-files-editor}
|
|
|
|
__ce_TZ=${TZ:-"America/Los_Angeles"}
|
|
|
|
__ce_Password=${Password:-password}
|
2022-10-09 22:40:49 -07:00
|
|
|
__ce_Deploy=${WEB_GENERATOR:-/opt/web-generator/deploy/$1}
|
|
|
|
if [[ ! -p $__ce_Deploy ]]; then
|
|
|
|
mkfifo $__ce_Deploy
|
|
|
|
fi
|
2021-01-15 07:41:34 -08:00
|
|
|
Parent_Folder=${Parent_Folder:-${HOME}/.local/share/code-edit}
|
2022-10-09 22:40:49 -07:00
|
|
|
__ce_Files=${Files:-${Parent_Folder}/$1/files}
|
2021-01-15 07:41:34 -08:00
|
|
|
mkdir -p ${__ce_Files}
|
2022-10-09 22:40:49 -07:00
|
|
|
__ce_Config=${Config:-${Parent_Folder}/$1/config}
|
2021-01-15 07:41:34 -08:00
|
|
|
mkdir -p ${__ce_Config}
|
|
|
|
__ce_Port=${Port:-8443}
|
|
|
|
|
2022-04-26 18:30:12 -07:00
|
|
|
echo "$(
|
|
|
|
set -o posix
|
|
|
|
set | grep __ce_ | sed 's/__ce_//'
|
|
|
|
)" >$SDIR/editors/docker.$1.env
|