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
! [ $QUIET ] \
&& echo "${ECHO_PREFIX}$@"
"$@"
$@
else
echo $@
fi
@ -186,52 +186,19 @@ xread(){
xreadpass(){
local PASS1
local PASS2
for attempt in 1 2 3 ; do
read -sep "password (Enter to skip): " PASS1
echo
if [ -z $PASS1 ] ; then
return
fi
read -sep "password (Enter to skip): " PASS1
echo
if [ $PASS1 ] ; then
read -sep "retype password: " PASS2
echo
if [[ $PASS1 != $PASS2 ]] ; then
echo "ERR: passwords do not match."
continue
return 1
fi
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
printf 'ready.\n'
sleep ${TIMEOUT:=5}
}
#
# readConfig
#
@ -325,10 +292,6 @@ buildAssets(){
local ASSETS_DIR=$2
ASSETS_DIR=${ASSETS_DIR:=assets}
if ! [ -e $TEMPLATE_DIR ] ; then
return
fi
local TEMPLATES=($(find "$TEMPLATE_DIR" -type f))
for file in "${TEMPLATES[@]}" ; do
file=${file#${TEMPLATE_DIR}}

View File

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

View File

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

View File

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

View File

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

View File

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