Skip to content

Commit b55fe2d

Browse files
committed
minor fixes to sh scripts to be POSIX compliant
1 parent abea741 commit b55fe2d

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

decompressed/gui_file/etc/modgui_scripts/02_specific.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extract_with_check() {
1818
continue
1919
fi
2020

21-
[ -n "$(echo "$file" | grep .md5sum)" ] && continue
21+
grep -q '.md5sum' "$file" && continue
2222

2323
orig_file=/$file
2424
file=$MD5_CHECK_DIR/$file

decompressed/gui_file/etc/modgui_scripts/03_various.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ checkver_cron() {
121121
rm /etc/crontabs/root #THIS CHECK A VALID ROOT CRON... we remove it as it's useless if the owner is not root.
122122
fi
123123
fi
124-
if [ ! -f /etc/crontabs/root ] || [ ! grep -q "checkver" /etc/crontabs/root ]; then
124+
if [ ! -f /etc/crontabs/root ] || ! grep -q "checkver" /etc/crontabs/root; then
125125
rand_h=$(awk -v min=1 -v max=6 'BEGIN{srand(); print int(min+rand()*(max-min+1))}')
126126
rand_m=$(awk -v min=1 -v max=59 'BEGIN{srand(); print int(min+rand()*(max-min+1))}')
127127
echo "$rand_m $rand_h * * * /usr/share/transformer/scripts/checkver >/dev/null 2>&1" >> /etc/crontabs/root
@@ -131,7 +131,7 @@ checkver_cron() {
131131
}
132132

133133
cron_christmas() {
134-
if [ ! -f /etc/crontabs/root ] || [ ! grep -q "christmas_tree" /etc/crontabs/root ]; then
134+
if [ ! -f /etc/crontabs/root ] || ! grep -q "christmas_tree" /etc/crontabs/root; then
135135
echo "*/30 * 24-26 12 * /etc/christmas_tree.sh &" >> /etc/crontabs/root
136136
fi
137137
}

decompressed/gui_file/etc/modgui_scripts/04_config.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ eco_param() {
112112
uci set power.cpu.cpuspeed='256'
113113
uci set power.cpu.wait='1'
114114
logecho "Restarting power management"
115-
/etc/init.d/power restart &>/dev/null
115+
/etc/init.d/power restart >/dev/null 2>&1
116116
fi
117117
}
118118

@@ -498,11 +498,11 @@ cumulative_check_gui() {
498498

499499
if [ ! "$(uci get -q modgui.gui.gui_hash)" ]; then
500500
uci set modgui.gui.new_ver="Unknown"
501-
uci set modgui.gui.gui_hash=$gui_hash
501+
uci set modgui.gui.gui_hash="$gui_hash"
502502
uci set modgui.gui.outdated_ver='0'
503-
elif [ "$(uci get -q modgui.gui.gui_hash)" != $gui_hash ]; then
503+
elif [ "$(uci get -q modgui.gui.gui_hash)" != "$gui_hash" ]; then
504504
uci set modgui.gui.new_ver="Unknown"
505-
uci set modgui.gui.gui_hash=$gui_hash
505+
uci set modgui.gui.gui_hash="$gui_hash"
506506
uci set modgui.gui.outdated_ver='0'
507507
fi
508508
if [ ! "$(uci get -q modgui.gui.autoupgrade)" ]; then

decompressed/gui_file/etc/modgui_scripts/06_network.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ puryfy_wan_interface() { #creano problemi di dns per chissa'  quale diavolo di
102102
fix_dns_dhcp_bug() {
103103
logecho "Fix DNS bug, make sure odhcp is enabled"
104104
#SET odhcpd MAINDHCP to 0 to use dnsmasq for ipv4
105-
if [ "$(uci get -q dhcp.odhcpd.maindhcp)" == "1" ]; then
105+
if [ "$(uci get -q dhcp.odhcpd.maindhcp)" = "1" ]; then
106106
logecho "Setting odhcpd not maindhcp"
107107
uci set dhcp.odhcpd.maindhcp="0"
108108
/etc/init.d/odhcpd restart
@@ -214,10 +214,10 @@ unlock_ssh_wan_tiscali() {
214214

215215
disable_tcp_Sack() {
216216
logecho "Apply CVE 2019-11477 workaround"
217-
if [ "$(cat /etc/sysctl.conf | grep 'net.ipv4.tcp_sack')" ]; then
217+
if grep -q 'net.ipv4.tcp_sack' /etc/sysctl.conf; then
218218
sed -i 's/\(net.ipv4.tcp_sack=\)1/\10/g' /etc/sysctl.conf
219219
sysctl -p 2>/dev/null 1>/dev/null
220-
elif [ -n "$(cat /etc/sysctl.conf | grep 'net.ipv4.tcp_sack=0')" ]; then
220+
elif ! grep -q 'net.ipv4.tcp_sack=0' /etc/sysctl.conf; then
221221
echo -e "\n" >>/etc/sysctl.conf
222222
echo "# disable tcp_sack for CVE 2019-11477" >>/etc/sysctl.conf
223223
echo "net.ipv4.tcp_sack=0" >>/etc/sysctl.conf
@@ -260,7 +260,7 @@ disable_tcp_Sack
260260
check_xtm_atmwan #needed for UNO firmware
261261

262262
logecho "Restarting dnsmasq if needed..."
263-
if [ $restart_dnsmasq -eq 1 ]; then
263+
if [ "$restart_dnsmasq" -eq 1 ]; then
264264
uci commit
265265
killall dnsmasq
266266
/etc/init.d/dnsmasq restart

0 commit comments

Comments
 (0)