2024-01-05 23:05:32 +03:00
|
|
|
#!/usr/bin/bash
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
cd $(dirname $0)
|
|
|
|
|
PATH=$PATH:$(dirname "$(pwd)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
source ../.pct-helpers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
2024-01-07 16:18:27 +03:00
|
|
|
readConfig
|
2024-01-05 23:05:32 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
DFL_ID=${DFL_ID:=301}
|
2024-01-05 23:11:31 +03:00
|
|
|
DFL_CTHOSTNAME=${DFL_CTHOSTNAME:=syncthing}
|
2024-01-05 23:05:32 +03:00
|
|
|
|
2024-01-07 16:34:47 +03:00
|
|
|
DFL_CORES=${DFL_CORES:=1}
|
2024-01-05 23:26:20 +03:00
|
|
|
DFL_RAM=${DFL_RAM:=1024}
|
2024-01-08 06:03:08 +03:00
|
|
|
DFL_SWAP=${DFL_SWAP:=${DFL_RAM}}
|
2024-01-05 23:26:20 +03:00
|
|
|
DFL_DRIVE=${DFL_DRIVE:=8}
|
2024-01-05 23:05:32 +03:00
|
|
|
|
|
|
|
|
WAN_IP=-
|
|
|
|
|
WAN_GATE=-
|
|
|
|
|
ADMIN_IP=-
|
|
|
|
|
ADMIN_GATE=-
|
2024-01-05 23:10:00 +03:00
|
|
|
LAN_IP=-
|
|
|
|
|
LAN_GATE=-
|
2024-01-05 23:05:32 +03:00
|
|
|
|
|
|
|
|
REBOOT=${REBOOT:=1}
|
|
|
|
|
|
|
|
|
|
readVars
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
OPTS_STAGE_1="\
|
|
|
|
|
--hostname $CTHOSTNAME \
|
2024-01-07 16:34:47 +03:00
|
|
|
--cores $CORES \
|
2024-01-05 23:05:32 +03:00
|
|
|
--memory $RAM \
|
|
|
|
|
--swap $SWAP \
|
2024-01-06 19:37:31 +03:00
|
|
|
--net0 name=lan,bridge=vmbr${LAN_BRIDGE},firewall=1,ip=dhcp,type=veth \
|
|
|
|
|
--net1 name=admin,bridge=vmbr${ADMIN_BRIDGE},firewall=1,ip=dhcp,type=veth \
|
2024-01-05 23:05:32 +03:00
|
|
|
--storage local-lvm \
|
|
|
|
|
--rootfs local-lvm:$DRIVE \
|
|
|
|
|
--unprivileged 1 \
|
2024-01-08 04:15:19 +03:00
|
|
|
--features nesting=1 \
|
2024-01-05 23:05:32 +03:00
|
|
|
${PCT_EXTRA} \
|
|
|
|
|
"
|
|
|
|
|
|
|
|
|
|
OPTS_STAGE_2="\
|
|
|
|
|
--onboot 1 \
|
|
|
|
|
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
echo "# Creating CT..."
|
|
|
|
|
pctCreateAlpine $ID "${OPTS_STAGE_1}" "$PASS"
|
|
|
|
|
|
|
|
|
|
echo "# Installing dependencies..."
|
|
|
|
|
@ lxc-attach $ID apk add bash syncthing
|
|
|
|
|
|
2024-01-05 23:32:36 +03:00
|
|
|
echo "# Setup: syncthing..."
|
2024-01-05 23:05:32 +03:00
|
|
|
@ lxc-attach $ID rc-update add syncthing
|
|
|
|
|
@ lxc-attach $ID rc-service syncthing start
|
2024-01-05 23:32:36 +03:00
|
|
|
|
|
|
|
|
echo "# Setup: dashboard..."
|
2024-01-06 01:49:27 +03:00
|
|
|
sleep ${TIMEOUT:=5}
|
|
|
|
|
@ lxc-attach $ID -- \
|
|
|
|
|
sed \
|
|
|
|
|
-e 's/127\.0\.0\.1:8384/0.0.0.0:8384/g' \
|
|
|
|
|
-i /var/lib/syncthing/.config/syncthing/config.xml
|
2024-01-05 23:05:32 +03:00
|
|
|
|
|
|
|
|
echo "# Post config..."
|
|
|
|
|
pctSet $ID "${OPTS_STAGE_2}" $REBOOT
|
|
|
|
|
|
|
|
|
|
echo "# Done."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
# vim:set ts=4 sw=4 :
|
|
|
|
|
|