Skip to content

Commit

Permalink
nc-automount: fix dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nacho committed Mar 4, 2018
1 parent 33fae1f commit 15a6b58
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build-SD.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ IP=$1 # First argument is the QEMU Raspbian IP address


[[ "$FTPPASS" == "" ]] && {
echo -e "\e[1mNo FTPPASS variable found, FTP won't work.\nYou probably want to cancel now"
echo -e "\e[1mNo FTPPASS variable found, FTP won't work.\nYou probably want to cancel now\e[0m"
sleep 5
}

Expand Down
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

[v0.46.36](https://github.com/nextcloud/nextcloudpi/commit/b071266) (2018-03-03) build: fix systemd dir not existing
[v0.46.37](https://github.com/nextcloud/nextcloudpi/commit/1044dbb) (2018-03-03) nc-automount: fix dependencies

[v0.46.36](https://github.com/nextcloud/nextcloudpi/commit/33fae1f) (2018-03-03) build: fix systemd dir not existing

[v0.46.35](https://github.com/nextcloud/nextcloudpi/commit/6aa39ed) (2018-02-26) ncp-web: add localization (#372)

Expand Down
8 changes: 6 additions & 2 deletions etc/nextcloudpi-config.d/fail2ban.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ ACTIVE_=no
BANTIME_=600

# cooldown time for incorrect passwords
FINDTIME_=600
FINDTIME_=600

# bad attempts before banning an IP
MAXRETRY_=6
MAXRETRY_=6

# email to send notifications to
EMAIL_=optional@email.com
Expand Down Expand Up @@ -65,6 +65,10 @@ EOF
sed -i 's|Fail2Ban|NextCloudPi|' /etc/fail2ban/action.d/sendmail-whois-lines.conf
grep -q actionstart_ "$F" || sed -i 's|actionstart|actionstart_|' "$F"
grep -q actionstop_ "$F" || sed -i 's|actionstop|actionstop_|' "$F"

# delay init because of automount
sed -i "/^ExecStart=/iExecStartPre=/bin/sleep 10" /lib/systemd/system/fail2ban.service

}

configure()
Expand Down
10 changes: 4 additions & 6 deletions etc/nextcloudpi-config.d/nc-automount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ EOF
cat > /usr/lib/systemd/system/nc-automount.service <<'EOF'
[Unit]
Description=Automount USB drives
Before=mysqld.service
Before=mysqld.service dphys-swapfile.service fail2ban.service smbd.service nfs-server.service
[Service]
Restart=always
Expand All @@ -51,6 +51,7 @@ EOF
cat > /usr/lib/systemd/system/nc-automount-links.service <<'EOF'
[Unit]
Description=Monitor /media for mountpoints and create USBdrive* symlinks
Before=nc-automount.service
[Service]
Restart=always
Expand Down Expand Up @@ -96,11 +97,8 @@ done
EOF
chmod +x /usr/local/etc/nc-automount-links-mon

# adjust when mariaDB starts
local DBUNIT=/lib/systemd/system/mariadb.service
grep -q sleep $DBUNIT || sed -i "/^ExecStart=/iExecStartPre=/bin/sleep 10" $DBUNIT

systemctl daemon-reload
# delay init because of automount
sed -i "/^ExecStart=/iExecStartPre=/bin/sleep 10" /lib/systemd/system/mariadb.service
}

configure()
Expand Down
2 changes: 1 addition & 1 deletion etc/nextcloudpi-config.d/nc-ramlogs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ EOF
[Unit]
Description=Populate ramlogs dir
Requires=network.target
Before=redis-server apache2 mysqld
Before=redis-server.service apache2.service mysqld.service
[Service]
ExecStart=/bin/bash /usr/local/bin/ramlog-dirs.sh
Expand Down
11 changes: 7 additions & 4 deletions etc/nextcloudpi-config.d/nc-swapfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,22 @@ configure()
sed -i "s|#\?CONF_SWAPSIZE=.*|CONF_SWAPSIZE=$SWAPSIZE_|" /etc/dphys-swapfile
grep -q vm.swappiness /etc/sysctl.conf || echo "vm.swappiness = 10" >> /etc/sysctl.conf && sysctl --load &>/dev/null

# workaround for automount, systemd doesn't get the order right
grep -q sleep /etc/init.d/dphys-swapfile || sed -i "/\<start)/asleep 15" /etc/init.d/dphys-swapfile

dphys-swapfile setup && dphys-swapfile swapon && {
[[ -f "$ORIG" ]] && swapoff "$ORIG" && rm -f "$ORIG"
echo "swapfile moved successfully"
return 0
}

echo "moving swapfile failed"
return 1
}

install() { :; }
install()
{
# delay init because of automount
sed -i "/\<start)/asleep 30" /etc/init.d/dphys-swapfile
}


# License
#
Expand Down
22 changes: 22 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,28 @@ EOF
grep -q '^ACTIVE_=yes$' /usr/local/etc/nextcloudpi-config.d/samba.sh || \
update-rc.d nmbd disable

# fix automount dependencies with other ncp-apps
sed -i \
's|^Before=.*|Before=mysqld.service dphys-swapfile.service fail2ban.service smbd.service nfs-server.service|' \
/usr/lib/systemd/system/nc-automount.service

sed -i \
's|^Before=.*|Before=nc-automount.service|' \
/usr/lib/systemd/system/nc-automount-links.service

# fix ramlogs dependencies with other ncp-apps
sed -i \
's|^Before=.*|Before=redis-server.service apache2.service mysqld.service|' \
/usr/lib/systemd/system/ramlogs.service

# adjust when other services start
DBUNIT=/lib/systemd/system/mariadb.service
F2BUNIT=/lib/systemd/system/fail2ban.service
SWPUNIT=/etc/init.d/dphys-swapfile
grep -q sleep "$DBUNIT" || sed -i "/^ExecStart=/iExecStartPre=/bin/sleep 10" "$DBUNIT"
grep -q sleep "$F2BUNIT" || sed -i "/^ExecStart=/iExecStartPre=/bin/sleep 10" "$F2BUNIT"
grep -q sleep "$SWPUNIT" || sed -i "/\<start)/asleep 30" "$SWPUNIT"

} # end - only live updates

exit 0
Expand Down

0 comments on commit 15a6b58

Please sign in to comment.