2020-08-02 20:15:13 +00:00
|
|
|
#!/usr/bin/with-contenv bash
|
|
|
|
|
|
|
|
####################
|
2020-08-03 22:24:11 +00:00
|
|
|
# Pictures storage
|
2020-08-02 20:15:13 +00:00
|
|
|
####################
|
2020-08-03 22:24:11 +00:00
|
|
|
if [ ! -d "/opt/pictures" ] ; then
|
|
|
|
mkdir /opt/pictures
|
|
|
|
fi
|
2020-08-02 20:15:13 +00:00
|
|
|
|
2020-08-04 06:39:09 +00:00
|
|
|
####################
|
|
|
|
# Ansible
|
|
|
|
####################
|
|
|
|
if [ ! -d "/opt/ansible" ] ; then
|
|
|
|
mkdir /opt/ansible
|
|
|
|
fi
|
2020-08-04 18:58:38 +00:00
|
|
|
if [ ! -f "/opt/ansible/ssh.key" ] ; then
|
2020-08-04 20:56:43 +00:00
|
|
|
ssh-keygen -t rsa -b 4096 -f /opt/ansible/ssh.key -N ''
|
|
|
|
echo "
|
|
|
|
-------------------------------------
|
|
|
|
Ansible SSH Key"
|
|
|
|
cat /opt/ansible/ssh.key.pub
|
|
|
|
echo "-------------------------------------
|
|
|
|
"
|
2020-08-04 18:58:38 +00:00
|
|
|
fi
|
2020-08-04 06:39:09 +00:00
|
|
|
if [ ! -d "/opt/ansible/roles" ] ; then
|
|
|
|
mkdir /opt/ansible/roles
|
|
|
|
fi
|
2020-08-04 20:56:43 +00:00
|
|
|
if [ ! -d "/opt/ansible/roles/wireguard" ] ; then
|
|
|
|
git clone https://git.kemonine.info/PiFrame/ansible-role-wireguard.git /opt/ansible/roles/wireguard
|
|
|
|
else
|
|
|
|
cd /opt/ansible/roles/wireguard
|
|
|
|
git pull
|
|
|
|
fi
|
2020-08-04 06:39:09 +00:00
|
|
|
|
2020-08-03 22:24:11 +00:00
|
|
|
####################
|
|
|
|
# WireGuard
|
|
|
|
####################
|
2020-08-02 20:15:13 +00:00
|
|
|
if [ "$ENABLE_WIREGUARD" = true ] ; then
|
|
|
|
ip link del dev test 2>/dev/null
|
|
|
|
if ip link add dev test type wireguard; then
|
|
|
|
echo "**** It seems the wireguard module is already active :) ****"
|
|
|
|
ip link del dev test
|
|
|
|
else
|
|
|
|
echo "**** The wireguard module is not active, please install wireguard on the host and activate the 'wg' kernel module ****"
|
|
|
|
fi
|
2020-08-04 20:59:30 +00:00
|
|
|
if [ ! -d "/opt/wireguard" ] ; then
|
|
|
|
mkdir /opt/wireguard
|
|
|
|
fi
|
2020-08-02 20:15:13 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
####################
|
2020-08-03 22:24:11 +00:00
|
|
|
# syncthing
|
2020-08-02 20:15:13 +00:00
|
|
|
####################
|
2020-08-03 22:24:11 +00:00
|
|
|
if [ "$ENABLE_SYNCTHING" = true ] ; then
|
|
|
|
if [ ! -d "/opt/syncthing" ]; then
|
|
|
|
mkdir /opt/syncthing
|
|
|
|
fi
|
|
|
|
ST_CONF="/opt/syncthing/config.xml"
|
|
|
|
if [ ! -f "$ST_CONF" ]; then
|
|
|
|
echo "**** Initial Syncthing Config ****"
|
|
|
|
/usr/bin/syncthing -generate /opt/syncthing
|
|
|
|
sed -i 's/<address>127.0.0.1:8384<\/address>/<address>0.0.0.0:8384<\/address>/g' /opt/syncthing/config.xml
|
|
|
|
sed -i 's/<folder id="default" label="Default Folder" path="\/root\/Sync" type="sendreceive" rescanIntervalS="3600" fsWatcherEnabled="true" fsWatcherDelayS="10" ignorePerms="false" autoNormalize="true">/<folder id="piframe-pictures" label="PiFrameFleet Pictures" path="\/opt\/pictures" type="sendonly" rescanIntervalS="86400" fsWatcherEnabled="true" fsWatcherDelayS="10" ignorePerms="false" autoNormalize="true">/g' /opt/syncthing/config.xml
|
|
|
|
if [ -d "/root/Sync" ]; then
|
|
|
|
rm -r /root/Sync
|
|
|
|
fi
|
|
|
|
fi
|
2020-08-02 20:15:13 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
####################
|
|
|
|
# FileBrowser
|
|
|
|
####################
|
|
|
|
if [ "$ENABLE_FILEBROWSER" = true ] ; then
|
|
|
|
if [ ! -d "/opt/filebrowser" ]; then
|
|
|
|
mkdir /opt/filebrowser
|
|
|
|
fi
|
|
|
|
FB_DB="/opt/filebrowser/pictures.db"
|
|
|
|
if [ ! -f "$FB_DB" ]; then
|
|
|
|
echo "**** Initial FileBrowser Config ****"
|
|
|
|
filebrowser -d $FB_DB \
|
|
|
|
config init 2>&1 > /dev/null
|
|
|
|
filebrowser -d $FB_DB \
|
|
|
|
config set --address 0.0.0.0 2>&1 > /dev/null
|
|
|
|
filebrowser -d $FB_DB \
|
|
|
|
config set --port 9191 2>&1 > /dev/null
|
|
|
|
filebrowser -d $FB_DB \
|
|
|
|
config set --branding.name "PiFrameFleet - Pictures" 2>&1 > /dev/null
|
|
|
|
filebrowser -d $FB_DB \
|
|
|
|
users add admin password 2>&1 > /dev/null
|
|
|
|
fi
|
|
|
|
fi
|