Compare commits

..

No commits in common. "74c1fdf5197c3e0eddfb2bdac6770a3478c3ba3d" and "90a142ad3c7a53484c4faf22c86e7f43ae27c72c" have entirely different histories.

6 changed files with 21 additions and 73 deletions

View File

@ -18,7 +18,7 @@ ECHO_PREFIX="### "
if [ -z $DRY_RUN ] ; then if [ -z $DRY_RUN ] ; then
! [ $QUIET ] \ ! [ $QUIET ] \
&& echo "${ECHO_PREFIX}$@" && echo "${ECHO_PREFIX}$@"
"$@" $@
else else
echo $@ echo $@
fi fi
@ -186,52 +186,19 @@ xread(){
xreadpass(){ xreadpass(){
local PASS1 local PASS1
local PASS2 local PASS2
for attempt in 1 2 3 ; do
read -sep "password (Enter to skip): " PASS1 read -sep "password (Enter to skip): " PASS1
echo echo
if [ -z $PASS1 ] ; then if [ $PASS1 ] ; then
return
fi
read -sep "retype password: " PASS2 read -sep "retype password: " PASS2
echo echo
if [[ $PASS1 != $PASS2 ]] ; then if [[ $PASS1 != $PASS2 ]] ; then
echo "ERR: passwords do not match." echo "ERR: passwords do not match."
continue return 1
fi fi
eval ''$1'='${PASS1}'' eval ''$1'='${PASS1}''
return
done
return 1
}
# Wait for /etc/inithooks.conf to be generated then cleared
#
# tklWaitForSetup
#
# for tkl inithooks doc see:
# https://www.turnkeylinux.org/docs/inithooks
tklWaitForSetup(){
printf "# TKL setup, this may take a while"
if [ -z $DRY_RUN ] ; then
while ! $(lxc-attach $ID -- test -e /etc/inithooks.conf) ; do
printf '.'
sleep ${TIMEOUT:=5}
done
printf '+'
sleep ${TIMEOUT:=5}
while ! [[ $(lxc-attach $ID -- cat /etc/inithooks.conf | wc -c) < 2 ]] ; do
printf '.'
sleep ${TIMEOUT:=5}
done
else
printf '.+..'
fi fi
printf 'ready.\n'
sleep ${TIMEOUT:=5}
} }
# #
# readConfig # readConfig
# #
@ -325,10 +292,6 @@ buildAssets(){
local ASSETS_DIR=$2 local ASSETS_DIR=$2
ASSETS_DIR=${ASSETS_DIR:=assets} ASSETS_DIR=${ASSETS_DIR:=assets}
if ! [ -e $TEMPLATE_DIR ] ; then
return
fi
local TEMPLATES=($(find "$TEMPLATE_DIR" -type f)) local TEMPLATES=($(find "$TEMPLATE_DIR" -type f))
for file in "${TEMPLATES[@]}" ; do for file in "${TEMPLATES[@]}" ; do
file=${file#${TEMPLATE_DIR}} file=${file#${TEMPLATE_DIR}}

View File

@ -51,7 +51,6 @@ OPTS_STAGE_1="\
--storage local-lvm \ --storage local-lvm \
--rootfs local-lvm:$DRIVE \ --rootfs local-lvm:$DRIVE \
--unprivileged 1 \ --unprivileged 1 \
--features nesting=1 \
${PCT_EXTRA} \ ${PCT_EXTRA} \
" "

View File

@ -39,7 +39,7 @@ readVars
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# NOTE: TKL gui will not function correctly without nesting enabled... # XXX cores...
OPTS_STAGE_1="\ OPTS_STAGE_1="\
--hostname $CTHOSTNAME \ --hostname $CTHOSTNAME \
--cores $CORES \ --cores $CORES \
@ -49,11 +49,11 @@ OPTS_STAGE_1="\
--storage local-lvm \ --storage local-lvm \
--rootfs local-lvm:$DRIVE \ --rootfs local-lvm:$DRIVE \
--unprivileged 1 \ --unprivileged 1 \
--features nesting=1 \
${PCT_EXTRA} \ ${PCT_EXTRA} \
" "
OPTS_STAGE_2="\ OPTS_STAGE_2="\
--startup order=90,up=10 \
--onboot 1 \ --onboot 1 \
" "
@ -68,27 +68,18 @@ getLatestTemplate '.*-turnkey-nextcloud' TEMPLATE
pctCreate $ID "$TEMPLATE" "$OPTS_STAGE_1" "$PASS" pctCreate $ID "$TEMPLATE" "$OPTS_STAGE_1" "$PASS"
sleep ${TIMEOUT:=5} sleep ${TIMEOUT:=5}
tklWaitForSetup #echo "# Starting TKL Setup (this may take a few minutes to start)..."
#@ lxc-attach $ID -- bash --login -i
##@ lxc-attach $ID -- /usr/sbin/trunkey-init
# XXX this breaks the rest of this script... #
echo "# Starting TKL UI..." #echo "# Updating config..."
@ lxc-attach $ID -- bash -c 'HUB_APIKEY=SKIP SEC_UPDATES=SKIP /usr/sbin/turnkey-init' ## XXX update /var/www/nextcloud/config/config.php
sleep 5 ## - trusted_domains
## - trusted_proxies
#@ lxc-attach $ID -- \
echo "# Updating config..." # sed \
# add gate IP to trusted_proxies... # -e 's/^\(\s*\)\('\''trusted_domains\)/\1'\''trusted_proxies'\'' =>\n\1array (\n\1\1'${GATE_LAN_IP}'\/32\n\1)\n\1\2/' \
@ lxc-attach $ID -- bash -c "\ # -i /var/www/nextcloud/config/config.php
sed -i \
-e \"/trusted_domains/i\\ 'trusted_proxies' =>\\n array (\\n '${GATE_LAN_IP/\/*}\\/32',\\n ),\" \
/var/www/nextcloud/config/config.php"
# add self IP to trusted_domains -- enable setup from local network...
IP=${DRY_RUN:=$(lxc-attach $ID -- hostname -I)}
@ lxc-attach $ID -- bash -c "\
sed -z -i \
-e \"s/\\(trusted_domains[^)]*\\)/\\1 2 => '${IP/ *}',\\n /\" \
/var/www/nextcloud/config/config.php"
echo "# Copying assets..." echo "# Copying assets..."
@ pct-push-r $ID ./assets / @ pct-push-r $ID ./assets /
@ -98,10 +89,6 @@ echo "# Disabling fail2ban..."
@ lxc-attach $ID systemctl stop fail2ban @ lxc-attach $ID systemctl stop fail2ban
@ lxc-attach $ID systemctl disable fail2ban @ lxc-attach $ID systemctl disable fail2ban
echo "# Updating system..."
@ lxc-attach $ID apt update
@ lxc-attach $ID apt upgrade
echo "# Post config..." echo "# Post config..."
pctSet $ID "${OPTS_STAGE_2}" $REBOOT pctSet $ID "${OPTS_STAGE_2}" $REBOOT

View File

@ -50,7 +50,6 @@ OPTS_STAGE_1="\
--storage local-lvm \ --storage local-lvm \
--rootfs local-lvm:$DRIVE \ --rootfs local-lvm:$DRIVE \
--unprivileged 1 \ --unprivileged 1 \
--features nesting=1 \
${PCT_EXTRA} \ ${PCT_EXTRA} \
" "

View File

@ -50,11 +50,11 @@ OPTS_STAGE_1="\
--storage local-lvm \ --storage local-lvm \
--rootfs local-lvm:$DRIVE \ --rootfs local-lvm:$DRIVE \
--unprivileged 1 \ --unprivileged 1 \
--features nesting=1 \
${PCT_EXTRA} \ ${PCT_EXTRA} \
" "
OPTS_STAGE_2="\ OPTS_STAGE_2="\
--startup order=90,up=10 \
--onboot 1 \ --onboot 1 \
" "

View File

@ -49,11 +49,11 @@ OPTS_STAGE_1="\
--storage local-lvm \ --storage local-lvm \
--rootfs local-lvm:$DRIVE \ --rootfs local-lvm:$DRIVE \
--unprivileged 1 \ --unprivileged 1 \
--features nesting=1 \
${PCT_EXTRA} \ ${PCT_EXTRA} \
" "
OPTS_STAGE_2="\ OPTS_STAGE_2="\
--startup order=90,up=10 \
--onboot 1 \ --onboot 1 \
" "