Commit a3c57c4b authored by Igor Pecovnik's avatar Igor Pecovnik
Browse files

syncthing RFC and various fixes

parent 2c7fc036
...@@ -82,7 +82,7 @@ function check_status ...@@ -82,7 +82,7 @@ function check_status
# #
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading install info ... " 5 28 dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading install info ... " 5 28
LIST=() LIST=()
LIST_CONST=5 LIST_CONST=3
# Samba # Samba
SAMBA_STATUS="$(check_if_installed samba && echo "on" || echo "off" )" SAMBA_STATUS="$(check_if_installed samba && echo "on" || echo "off" )"
LIST+=( "Samba" "Windows compatible file sharing" "$SAMBA_STATUS" ) LIST+=( "Samba" "Windows compatible file sharing" "$SAMBA_STATUS" )
...@@ -95,7 +95,7 @@ if [[ "$family" == "Ubuntu" ]]; then ...@@ -95,7 +95,7 @@ if [[ "$family" == "Ubuntu" ]]; then
LIST+=( "TV headend" "TV streaming / proxy" "$TVHEADEND_STATUS" ) LIST+=( "TV headend" "TV streaming / proxy" "$TVHEADEND_STATUS" )
fi fi
# synthing # synthing
SYNCTHING_STATUS="$(check_if_installed syncthing && echo "on" || echo "off" )" SYNCTHING_STATUS="$([[ -d /usr/bin/syncthing ]] && echo "on" || echo "off" )"
LIST+=( "Syncthing" "Personal cloud @syncthing.net" "$SYNCTHING_STATUS" ) LIST+=( "Syncthing" "Personal cloud @syncthing.net" "$SYNCTHING_STATUS" )
# Exagear # Exagear
if [[ "$(check_if_installed xserver-xorg && echo "on")" == "on" && "$family" == "Ubuntu" ]]; then if [[ "$(check_if_installed xserver-xorg && echo "on")" == "on" && "$family" == "Ubuntu" ]]; then
...@@ -103,7 +103,7 @@ if [[ "$(check_if_installed xserver-xorg && echo "on")" == "on" && "$family" == ...@@ -103,7 +103,7 @@ if [[ "$(check_if_installed xserver-xorg && echo "on")" == "on" && "$family" ==
LIST+=( "ExaGear" "32bit x86 Linux/Windows emulator trial" "$EXAGEAR_STATUS" ) LIST+=( "ExaGear" "32bit x86 Linux/Windows emulator trial" "$EXAGEAR_STATUS" )
fi fi
if [[ "$(dpkg --print-architecture)" == "armhf" || "$(dpkg --print-architecture)" == "amd64" ]]; then if [[ "$(dpkg --print-architecture)" == "armhf" || "$(dpkg --print-architecture)" == "amd64" ]]; then
LIST_CONST=4 LIST_CONST=2
# vpn server # vpn server
VPN_SERVER_STATUS="$([[ -d /usr/local/vpnserver ]] && echo "on" || echo "off" )" VPN_SERVER_STATUS="$([[ -d /usr/local/vpnserver ]] && echo "on" || echo "off" )"
LIST+=( "VPN server" "Softether VPN server" "$VPN_SERVER_STATUS" ) LIST+=( "VPN server" "Softether VPN server" "$VPN_SERVER_STATUS" )
...@@ -113,7 +113,7 @@ if [[ "$(dpkg --print-architecture)" == "armhf" || "$(dpkg --print-architecture) ...@@ -113,7 +113,7 @@ if [[ "$(dpkg --print-architecture)" == "armhf" || "$(dpkg --print-architecture)
fi fi
# OMV # OMV
OMV_STATUS="$(check_if_installed openmediavault && echo "on" || echo "off" )" OMV_STATUS="$(check_if_installed openmediavault && echo "on" || echo "off" )"
[[ "$family" != "Ubuntu" ]] && LIST+=( "OMV" "OpenMediaVault NAS solution" "$OMV_STATUS" ) && LIST_CONST=5 [[ "$family" != "Ubuntu" ]] && LIST+=( "OMV" "OpenMediaVault NAS solution" "$OMV_STATUS" ) && LIST_CONST=3
# Plex # Plex
PLEX_STATUS="$((check_if_installed plexmediaserver || check_if_installed plexmediaserver-installer) && echo "on" || echo "off" )" PLEX_STATUS="$((check_if_installed plexmediaserver || check_if_installed plexmediaserver-installer) && echo "on" || echo "off" )"
LIST+=( "Plex" "Plex media server" "$PLEX_STATUS" ) LIST+=( "Plex" "Plex media server" "$PLEX_STATUS" )
...@@ -583,8 +583,9 @@ install_urbackup () ...@@ -583,8 +583,9 @@ install_urbackup ()
# #
# Client/server backup system https://www.urbackup.org/ # Client/server backup system https://www.urbackup.org/
# #
if [ "$(dpkg --print-architecture | grep arm64)" == "arm64" ]; then local arch=armhf; else local arch=$(dpkg --print-architecture); fi
PREFIX="http://hndl.urbackup.org/Server/latest/" PREFIX="http://hndl.urbackup.org/Server/latest/"
URL="http://hndl.urbackup.org/Server/latest/"$(wget -q $PREFIX -O - | html2text -width 120 | grep deb | awk ' { print $3 }' | grep $(dpkg --print-architecture)) URL="http://hndl.urbackup.org/Server/latest/"$(wget -q $PREFIX -O - | html2text -width 120 | grep deb | awk ' { print $3 }' | grep $arch)
fancy_wget "$URL" "-O ${TEMP_DIR}/package.deb" fancy_wget "$URL" "-O ${TEMP_DIR}/package.deb"
dpkg -i ${TEMP_DIR}/package.deb >/dev/null 2>&1 dpkg -i ${TEMP_DIR}/package.deb >/dev/null 2>&1
apt-get -yy -f install apt-get -yy -f install
...@@ -673,55 +674,39 @@ install_syncthing () ...@@ -673,55 +674,39 @@ install_syncthing ()
# Install Personal cloud https://syncthing.net/ # Install Personal cloud https://syncthing.net/
# #
add_choose_user if [ "$(dpkg --print-architecture | grep armhf)" == "armhf" ]; then
curl -s https://syncthing.net/release-key.txt | apt-key add - >/dev/null 2>&1 local filename="linux-arm"
if !(grep -qs syncthing "/etc/apt/sources.list.d/syncthing.list");then elif [ "$(dpkg --print-architecture | grep arm64)" == "arm64" ]; then
echo "deb http://apt.syncthing.net/ syncthing release" | tee /etc/apt/sources.list.d/syncthing.list local filename="linux-arm64"
else
local filename="linux-amd64"
fi fi
debconf-apt-progress -- apt-get update mkdir -p /usr/bin/syncthing
install_packet "syncthing syncthing-inotify" "Install Personal cloud https://syncthing.net/" wgeturl=$(curl -s "https://api.github.com/repos/syncthing/syncthing/releases" | grep $filename | grep 'browser_download_url' | head -1 | cut -d \" -f 4)
cat <<EOT > /etc/systemd/system/syncthing.service fancy_wget "$wgeturl" "-O ${TEMP_DIR}/syncthing.tgz"
[Unit] wgeturl=$(curl -s "https://api.github.com/repos/syncthing/syncthing-inotify/releases" | grep $filename | grep 'browser_download_url' | head -1 | cut -d \" -f 4)
Description=Syncthing - Open Source Continuous File Synchronization fancy_wget "$wgeturl" "-O ${TEMP_DIR}/syncthing-inotify.tgz"
Documentation=man:syncthing(1) tar xf ${TEMP_DIR}/syncthing.tgz -C ${TEMP_DIR}
After=network.target tar xf ${TEMP_DIR}/syncthing-inotify.tgz -C /usr/bin/syncthing
cp -R ${TEMP_DIR}/syncthing-*/syncthing /usr/bin/syncthing/
[Service] cp ${TEMP_DIR}/syncthing-*/etc/linux-systemd/system/syncthing* /etc/systemd/system/
ExecStart=/usr/bin/syncthing -no-browser -no-restart -logfile=/var/log/syncthing.log -logflags=3 cp /etc/systemd/system/syncthing@.service /etc/systemd/system/syncthing-inotify@.service
Restart=on-failure
SuccessExitStatus=3 4 # adjust service for inotify
RestartForceExitStatus=3 4 sed -i "s/^Description=.*/Description=Syncthing Inotify File Watcher/" /etc/systemd/system/syncthing-inotify@.service
User=$CHOSEN_USER sed -i "s/^After=.*/After=network.target syncthing.service/" /etc/systemd/system/syncthing-inotify@.service
sed -i "s/^ExecStart=.*/ExecStart=\/usr\/bin\/syncthing-inotify -logfile=\/var\/log\/syncthing-inotify.log -logflags=3/" /etc/systemd/system/syncthing-inotify@.service
sed -i "/^\[Install\]/a Requires=syncthing.service" /etc/systemd/system/syncthing-inotify@.service
[Install]
WantedBy=default.target
EOT
cat <<EOT > /etc/systemd/system/syncthing-inotify.service
[Unit]
Description=Syncthing Inotify File Watcher
After=network.target syncthing.service
Requires=syncthing.service
[Service]
User=$CHOSEN_USER
ExecStart=/usr/bin/syncthing-inotify -logfile=/var/log/syncthing-inotify.log -logflags=3
SuccessExitStatus=2
RestartForceExitStatus=3
Restart=on-failure
ProtectSystem=full
ProtectHome=read-only
[Install]
WantedBy=multi-user.target
EOT
# increase open file limit # increase open file limit
if !(grep -qs "fs.inotify.max_user_watches=204800" "/etc/sysctl.conf");then if !(grep -qs "fs.inotify.max_user_watches=204800" "/etc/sysctl.conf");then
echo -e "fs.inotify.max_user_watches=204800" | tee -a /etc/sysctl.conf echo -e "fs.inotify.max_user_watches=204800" | tee -a /etc/sysctl.conf
fi fi
systemctl enable syncthing add_choose_user
systemctl start syncthing systemctl enable syncthing@${CHOSEN_USER}.service
systemctl enable syncthing-inotify systemctl start syncthing@${CHOSEN_USER}.service
systemctl start syncthing-inotify systemctl enable syncthing-inotify@${CHOSEN_USER}.service
systemctl start syncthing-inotify@${CHOSEN_USER}.service
} }
...@@ -1363,6 +1348,8 @@ mysql_pass="" ...@@ -1363,6 +1348,8 @@ mysql_pass=""
BACKTITLE="Softy - Armbian post deployment scripts, http://www.armbian.com" BACKTITLE="Softy - Armbian post deployment scripts, http://www.armbian.com"
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#check_status
# main dialog routine # main dialog routine
# #
DIALOG_CANCEL=1 DIALOG_CANCEL=1
...@@ -1372,11 +1359,10 @@ while true; do ...@@ -1372,11 +1359,10 @@ while true; do
# prepare menu items # prepare menu items
check_status check_status
LISTLENGHT="$(($LIST_CONST+${#LIST[@]}/2))" LISTLENGHT="$((${#LIST[@]}/2))"
exec 3>&1 exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --title "Installing to $family $distribution" --clear --cancel-label \ selection=$(dialog --backtitle "$BACKTITLE" --title "Installing to $family $distribution" --clear --cancel-label \
"Exit" --checklist "\nChoose what you want to install:\n " $LISTLENGHT 70 15 "${LIST[@]}" 2>&1 1>&3) "Exit" --checklist "\nChoose what you want to install:\n " $(($LISTLENGHT+$LIST_CONST)) 70 15 "${LIST[@]}" 2>&1 1>&3)
exit_status=$? exit_status=$?
exec 3>&- exec 3>&-
case $exit_status in case $exit_status in
...@@ -1480,8 +1466,8 @@ while true; do ...@@ -1480,8 +1466,8 @@ while true; do
if [[ "$selection" == *Transmission* && "$TRANSMISSION_STATUS" != "on" ]]; then if [[ "$selection" == *Transmission* && "$TRANSMISSION_STATUS" != "on" ]]; then
install_transmission install_transmission
check_port 9091 transmission check_port 9091 transmission
dialog --title "Seed Armbian torrents" --backtitle "$BACKTITLE" --yes-label "Yes" --no-label "Cancel" --yesno "\nDo you want to help \ dialog --title "Seed Armbian torrents" --backtitle "$BACKTITLE" --yes-label "Yes" --no-label "Cancel" --yesno "\n\
community and seed armbian torrent files? It will ensure faster download for everyone. We need around 50Gb of your space." 10 44 Do you want to help community and seed armbian torrent files? It will ensure faster download for everyone. We need around 50Gb of your space." 10 44
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
install_transmission_seed_armbian_torrents install_transmission_seed_armbian_torrents
fi fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment