diff --git a/.pct-helpers b/.pct-helpers index 08638cb..9c3e311 100644 --- a/.pct-helpers +++ b/.pct-helpers @@ -148,7 +148,6 @@ normpath(){ # https://pve.proxmox.com/wiki/Linux_Container getLatestTemplate(){ #IFS=$'\n' - local pattern=$1 local templates=($(pveam available | grep -o ''${1}'.*$')) local latest=${templates[-1]} @@ -198,6 +197,18 @@ xreadpass(){ fi } +# +# readConfig +# +readConfig(){ + if [ -z $NO_DEFAULTS ] ; then + [ -e ../config.global ] \ + && source ../config.global + [ -e ./config ] \ + && source ./config + fi +} + # # readVars # diff --git a/Makefile b/Makefile index 1875959..db6cf2d 100644 --- a/Makefile +++ b/Makefile @@ -29,9 +29,17 @@ wireguard: syncthing: $@/make.sh +.PHONY: nextcloud +nextcloud: + $@/make.sh + +.PHONY: gitea +gitea: + $@/make.sh + .PHONY: all -all: config gate ns ssh wireguard syncthing +all: config gate ns ssh wireguard syncthing nextcloud gitea diff --git a/gate-traefik/make.sh b/gate-traefik/make.sh index 18040dc..4a6d87d 100755 --- a/gate-traefik/make.sh +++ b/gate-traefik/make.sh @@ -12,11 +12,7 @@ source ../.pct-helpers #---------------------------------------------------------------------- -[ -e ../config.global ] \ - && source ../config.global - -[ -e ./config ] \ - && source ./config +readConfig #---------------------------------------------------------------------- diff --git a/nextcloud/assets/etc/network/.pve-ignore.interfaces b/nextcloud/assets/etc/network/.pve-ignore.interfaces new file mode 100644 index 0000000..e69de29 diff --git a/nextcloud/assets/etc/network/interfaces b/nextcloud/assets/etc/network/interfaces new file mode 100644 index 0000000..288a91e --- /dev/null +++ b/nextcloud/assets/etc/network/interfaces @@ -0,0 +1,7 @@ +auto lo +iface lo inet loopback + +auto lan +iface lan inet dhcp + hostname $(hostname) + diff --git a/nextcloud/make.sh b/nextcloud/make.sh new file mode 100644 index 0000000..827bcb5 --- /dev/null +++ b/nextcloud/make.sh @@ -0,0 +1,100 @@ +#!/usr/bin/bash +#---------------------------------------------------------------------- + +cd $(dirname $0) +PATH=$PATH:$(dirname "$(pwd)") + + +#---------------------------------------------------------------------- + +source ../.pct-helpers + + +#---------------------------------------------------------------------- + +readConfig + + +#---------------------------------------------------------------------- + +DFL_ID=${DFL_ID:=300} +DFL_CTHOSTNAME=${DFL_CTHOSTNAME:=nextcloud} + +DFL_RAM=${DFL_RAM:=2048} +DFL_SWAP=${DFL_SWAP:=${DFL_RAM:=2048}} +DFL_DRIVE=${DFL_DRIVE:=40} + +WAN_IP=- +WAN_GATE=- +ADMIN_IP=- +ADMIN_GATE=- +LAN_IP=- +LAN_GATE=- + +REBOOT=${REBOOT:=1} + +readVars + + +#---------------------------------------------------------------------- + +# XXX cores... +OPTS_STAGE_1="\ + --cores 2 \ + --hostname $CTHOSTNAME \ + --memory $RAM \ + --swap $SWAP \ + --net0 name=lan,bridge=vmbr${LAN_BRIDGE},firewall=1,ip=dhcp,type=veth \ + --storage local-lvm \ + --rootfs local-lvm:$DRIVE \ + --unprivileged 1 \ + ${PCT_EXTRA} \ +" + +OPTS_STAGE_2="\ + --startup order=90,up=10 \ + --onboot 1 \ +" + + +#---------------------------------------------------------------------- + +echo "# Building config..." +buildAssets "$TEMPLATE_DIR" "$ASSETS_DIR" + +echo "# Creating CT..." +getLatestTemplate '.*-turnkey-nextcloud' TEMPLATE +pctCreate $ID "$TEMPLATE" "$OPTS_STAGE_1" "$PASS" + +echo "# Starting TKL Setup (this may take a few minutes to start)..." +@ lxc-attach $ID -- bash --login -c exit +@ 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 / + +echo "# Disabling fail2ban..." +# NOTE: we do not need this as we'll be running from behind a reverse proxy... +@ lxc-attach $ID systemctl stop fail2ban +@ lxc-attach $ID systemctl disable fail2ban + +echo "# Post config..." +pctSet $ID "${OPTS_STAGE_2}" $REBOOT + +echo "# Done." + + + +#---------------------------------------------------------------------- +# vim:set ts=4 sw=4 : + + diff --git a/ns/make.sh b/ns/make.sh index 96af74b..746ebc0 100755 --- a/ns/make.sh +++ b/ns/make.sh @@ -12,11 +12,7 @@ source ../.pct-helpers #---------------------------------------------------------------------- -[ -e ../config.global ] \ - && source ../config.global - -[ -e ./config ] \ - && source ./config +readConfig #---------------------------------------------------------------------- diff --git a/ssh/make.sh b/ssh/make.sh index 3cf65b9..0723588 100755 --- a/ssh/make.sh +++ b/ssh/make.sh @@ -12,11 +12,7 @@ source ../.pct-helpers #---------------------------------------------------------------------- -[ -e ../config.global ] \ - && source ../config.global - -[ -e ./config ] \ - && source ./config +readConfig #---------------------------------------------------------------------- diff --git a/syncthing/make.sh b/syncthing/make.sh index 09efba6..dc3e471 100755 --- a/syncthing/make.sh +++ b/syncthing/make.sh @@ -12,11 +12,7 @@ source ../.pct-helpers #---------------------------------------------------------------------- -[ -e ../config.global ] \ - && source ../config.global - -[ -e ./config ] \ - && source ./config +readConfig #----------------------------------------------------------------------