diff --git a/firewall_off.sh b/firewall_off.sh index 9f3748c..4766b21 100644 --- a/firewall_off.sh +++ b/firewall_off.sh @@ -18,7 +18,8 @@ # You can download the latest version of this script from: # https://github.com/MiSTer-devel/Scripts_MiSTer -# Version 1.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. +# Version 1.0.2 - 2019-02-03 - Remounting / as RW only when needed; downgraded version from 1.1 to 1.0.2. +# Version 1.0.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. # Version 1.0 - 2019-02-02 - First commit @@ -31,10 +32,11 @@ then fi echo "*filter"$'\n'"COMMIT" | iptables-restore -mount / -o remount,rw +mount | grep -q "on / .*[(,]ro[,$]" && RO_ROOT="true" +[ "$RO_ROOT" == "true" ] && mount / -o remount,rw rm /etc/network/if-pre-up.d/iptables > /dev/null 2>&1 sync -mount / -o remount,ro +[ "$RO_ROOT" == "true" ] && mount / -o remount,ro echo "Firewall is off and" echo "inactive at startup." diff --git a/firewall_on.sh b/firewall_on.sh index 7d69077..4055e7e 100644 --- a/firewall_on.sh +++ b/firewall_on.sh @@ -18,7 +18,8 @@ # You can download the latest version of this script from: # https://github.com/MiSTer-devel/Scripts_MiSTer -# Version 1.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. +# Version 1.0.2 - 2019-02-03 - Remounting / as RW only when needed; downgraded version from 1.1 to 1.0.2. +# Version 1.0.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. # Version 1.0 - 2019-02-02 - First commit @@ -103,11 +104,12 @@ then IPTABLES_UP_RULES=$IPTABLES_UP_RULES$'\n'"COMMIT" echo "$IPTABLES_UP_RULES" > /media/fat/linux/iptables.up.rules fi -mount / -o remount,rw +mount | grep "on / .*[(,]ro[,$]" -q && RO_ROOT="true" +[ "$RO_ROOT" == "true" ] && mount / -o remount,rw echo "#!/bin/bash"$'\n'"iptables-restore < /media/fat/linux/iptables.up.rules" > /etc/network/if-pre-up.d/iptables chmod +x /etc/network/if-pre-up.d/iptables sync -mount / -o remount,ro +[ "$RO_ROOT" == "true" ] && mount / -o remount,ro /etc/network/if-pre-up.d/iptables echo "Firewall is on and" diff --git a/ftp_off.sh b/ftp_off.sh index 21f8945..50835f5 100644 --- a/ftp_off.sh +++ b/ftp_off.sh @@ -18,7 +18,8 @@ # You can download the latest version of this script from: # https://github.com/MiSTer-devel/Scripts_MiSTer -# Version 1.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. +# Version 1.0.2 - 2019-02-03 - Remounting / as RW only when needed; downgraded version from 1.1 to 1.0.2. +# Version 1.0.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. # Version 1.0 - 2019-02-02 - First commit @@ -30,11 +31,12 @@ then exit 1 fi -/etc/init.d/S50proftpd stop -mount / -o remount,rw +/etc/init.d/S50proftpd stop 2> /dev/null +mount | grep -q "on / .*[(,]ro[,$]" && RO_ROOT="true" +[ "$RO_ROOT" == "true" ] && mount / -o remount,rw mv /etc/init.d/S50proftpd /etc/init.d/_S50proftpd > /dev/null 2>&1 sync -mount / -o remount,ro +[ "$RO_ROOT" == "true" ] && mount / -o remount,ro if [ -f /media/fat/linux/iptables.up.rules ] then sed -e '/--dport 21 /s/^#*/#/g' -i /media/fat/linux/iptables.up.rules diff --git a/ftp_on.sh b/ftp_on.sh index 089e258..5617855 100644 --- a/ftp_on.sh +++ b/ftp_on.sh @@ -18,7 +18,8 @@ # You can download the latest version of this script from: # https://github.com/MiSTer-devel/Scripts_MiSTer -# Version 1.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. +# Version 1.0.2 - 2019-02-03 - Remounting / as RW only when needed; downgraded version from 1.1 to 1.0.2. +# Version 1.0.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. # Version 1.0 - 2019-02-02 - First commit @@ -30,10 +31,11 @@ then exit 1 fi -mount / -o remount,rw +mount | grep "on / .*[(,]ro[,$]" -q && RO_ROOT="true" +[ "$RO_ROOT" == "true" ] && mount / -o remount,rw mv /etc/init.d/_S50proftpd /etc/init.d/S50proftpd > /dev/null 2>&1 sync -mount / -o remount,ro +[ "$RO_ROOT" == "true" ] && mount / -o remount,ro if [ -f /media/fat/linux/iptables.up.rules ] then sed -e '/--dport 21 /s/^#//g' -i /media/fat/linux/iptables.up.rules diff --git a/samba_off.sh b/samba_off.sh index 0351be3..9d57e7e 100644 --- a/samba_off.sh +++ b/samba_off.sh @@ -18,7 +18,8 @@ # You can download the latest version of this script from: # https://github.com/MiSTer-devel/Scripts_MiSTer -# Version 1.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. +# Version 1.0.2 - 2019-02-03 - Remounting / as RW only when needed; downgraded version from 1.1 to 1.0.2. +# Version 1.0.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. # Version 1.0 - 2019-02-02 - First commit @@ -30,11 +31,12 @@ then exit 1 fi -/etc/init.d/S91smb stop -mount / -o remount,rw +/etc/init.d/S91smb stop 2> /dev/null +mount | grep -q "on / .*[(,]ro[,$]" && RO_ROOT="true" +[ "$RO_ROOT" == "true" ] && mount / -o remount,rw mv /etc/init.d/S91smb /etc/init.d/_S91smb > /dev/null 2>&1 sync -mount / -o remount,ro +[ "$RO_ROOT" == "true" ] && mount / -o remount,ro if [ -f /media/fat/linux/iptables.up.rules ] then sed -e '/--dport 137 /s/^#*/#/g' -i /media/fat/linux/iptables.up.rules diff --git a/samba_on.sh b/samba_on.sh index dbba048..1615c9e 100644 --- a/samba_on.sh +++ b/samba_on.sh @@ -18,7 +18,8 @@ # You can download the latest version of this script from: # https://github.com/MiSTer-devel/Scripts_MiSTer -# Version 1.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. +# Version 1.0.2 - 2019-02-03 - Remounting / as RW only when needed; downgraded version from 1.1 to 1.0.2. +# Version 1.0.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. # Version 1.0 - 2019-02-02 - First commit @@ -30,10 +31,11 @@ then exit 1 fi -mount / -o remount,rw +mount | grep "on / .*[(,]ro[,$]" -q && RO_ROOT="true" +[ "$RO_ROOT" == "true" ] && mount / -o remount,rw mv /etc/init.d/_S91smb /etc/init.d/S91smb > /dev/null 2>&1 sync -mount / -o remount,ro +[ "$RO_ROOT" == "true" ] && mount / -o remount,ro if [ -f /media/fat/linux/iptables.up.rules ] then sed -e '/--dport 137 /s/^#//g' -i /media/fat/linux/iptables.up.rules diff --git a/ssh_off.sh b/ssh_off.sh index 55e448e..66d8957 100644 --- a/ssh_off.sh +++ b/ssh_off.sh @@ -18,7 +18,8 @@ # You can download the latest version of this script from: # https://github.com/MiSTer-devel/Scripts_MiSTer -# Version 1.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. +# Version 1.0.2 - 2019-02-03 - Remounting / as RW only when needed; downgraded version from 1.1 to 1.0.2. +# Version 1.0.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. # Version 1.0 - 2019-02-02 - First commit @@ -30,11 +31,12 @@ then exit 1 fi -/etc/init.d/S50sshd stop -mount / -o remount,rw +/etc/init.d/S50sshd stop 2> /dev/null +mount | grep -q "on / .*[(,]ro[,$]" && RO_ROOT="true" +[ "$RO_ROOT" == "true" ] && mount / -o remount,rw mv /etc/init.d/S50sshd /etc/init.d/_S50sshd > /dev/null 2>&1 sync -mount / -o remount,ro +[ "$RO_ROOT" == "true" ] && mount / -o remount,ro if [ -f /media/fat/linux/iptables.up.rules ] then sed -e '/--dport 22 /s/^#*/#/g' -i /media/fat/linux/iptables.up.rules diff --git a/ssh_on.sh b/ssh_on.sh index b12519a..389503b 100644 --- a/ssh_on.sh +++ b/ssh_on.sh @@ -18,7 +18,8 @@ # You can download the latest version of this script from: # https://github.com/MiSTer-devel/Scripts_MiSTer -# Version 1.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. +# Version 1.0.2 - 2019-02-03 - Remounting / as RW only when needed; downgraded version from 1.1 to 1.0.2. +# Version 1.0.1 - 2019-02-02 - Remounting / as RW before altering /etc/init.d/ so the script actually works from OSD. # Version 1.0 - 2019-02-02 - First commit @@ -30,10 +31,11 @@ then exit 1 fi -mount / -o remount,rw +mount | grep "on / .*[(,]ro[,$]" -q && RO_ROOT="true" +[ "$RO_ROOT" == "true" ] && mount / -o remount,rw mv /etc/init.d/_S50sshd /etc/init.d/S50sshd > /dev/null 2>&1 sync -mount / -o remount,ro +[ "$RO_ROOT" == "true" ] && mount / -o remount,ro if [ -f /media/fat/linux/iptables.up.rules ] then sed -e '/--dport 22 /s/^#//g' -i /media/fat/linux/iptables.up.rules