format scripts with tabs, replace backticks, refactor

pull/770/head
Paul Philippov 2023-05-07 13:56:48 -04:00
parent 55dbb4d84b
commit 1e23d4a7fc
21 changed files with 167 additions and 239 deletions

View File

@ -13,8 +13,7 @@ SYSLOGD_ARGS="-C64 -t"
start() { start() {
printf 'Starting %s: ' "$DAEMON" printf 'Starting %s: ' "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting # shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" \ start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" -- -n $SYSLOGD_ARGS
-- -n $SYSLOGD_ARGS
status=$? status=$?
if [ "$status" -eq 0 ]; then if [ "$status" -eq 0 ]; then
echo "OK" echo "OK"
@ -45,10 +44,10 @@ restart() {
case "$1" in case "$1" in
start|stop|restart) start|stop|restart)
"$1";; "$1" ;;
reload) reload)
# Restart, since there is no true "reload" feature. # Restart, since there is no true "reload" feature.
restart;; restart ;;
*) *)
echo "Usage: $0 {start|stop|restart|reload}" echo "Usage: $0 {start|stop|restart|reload}"
exit 1 exit 1

View File

@ -31,18 +31,11 @@ stop()
} }
case "$1" in case "$1" in
start) start|stop)
start "$1" ;;
;;
stop)
stop
;;
restart|reload) restart|reload)
stop stop; start ;;
start
;;
*) *)
echo "Usage: $0 {start|stop|restart|reload}" >&2 echo "Usage: $0 {start|stop|restart|reload}" >&2
exit 1 exit 1
;;
esac esac

View File

@ -6,7 +6,7 @@
case "$1" in case "$1" in
start) start)
echo "Starting mdev..." echo "Starting mdev..."
# echo /sbin/mdev >/proc/sys/kernel/hotplug echo /sbin/mdev >/proc/sys/kernel/hotplug
/sbin/mdev -s /sbin/mdev -s
;; ;;
stop) stop)

View File

@ -13,8 +13,7 @@ NTPD_ARGS="-n"
start() { start() {
printf 'Starting %s: ' "$DAEMON" printf 'Starting %s: ' "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting # shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \ start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $NTPD_ARGS
-- $NTPD_ARGS
status=$? status=$?
if [ "$status" -eq 0 ]; then if [ "$status" -eq 0 ]; then
echo "OK" echo "OK"
@ -45,10 +44,9 @@ restart() {
case "$1" in case "$1" in
start|stop|restart) start|stop|restart)
"$1";; "$1" ;;
reload) reload)
# Restart, since there is no true "reload" feature. restart ;;
restart;;
*) *)
echo "Usage: $0 {start|stop|restart|reload}" echo "Usage: $0 {start|stop|restart|reload}"
exit 1 exit 1

View File

@ -14,9 +14,7 @@ start() {
# create the directory pointed to by the symlink. # create the directory pointed to by the symlink.
# - the filesystem is RW (i.e. we can rm the symlink), # - the filesystem is RW (i.e. we can rm the symlink),
# replace the symlink with an actual directory # replace the symlink with an actual directory
if [ -L /etc/dropbear \ if [ -L /etc/dropbear -a "$(readlink /etc/dropbear)" = "/var/run/dropbear" ]; then
-a "$(readlink /etc/dropbear)" = "/var/run/dropbear" ]
then
if rm -f /etc/dropbear >/dev/null 2>&1; then if rm -f /etc/dropbear >/dev/null 2>&1; then
mkdir -p /etc/dropbear mkdir -p /etc/dropbear
else else
@ -29,8 +27,7 @@ start() {
printf "Starting dropbear sshd: " printf "Starting dropbear sshd: "
umask 077 umask 077
start-stop-daemon -S -q -p /var/run/dropbear.pid \ start-stop-daemon -S -q -p /var/run/dropbear.pid --exec /usr/sbin/dropbear -- $DROPBEAR_ARGS
--exec /usr/sbin/dropbear -- $DROPBEAR_ARGS
[ $? = 0 ] && echo "OK" || echo "FAIL" [ $? = 0 ] && echo "OK" || echo "FAIL"
} }
stop() { stop() {
@ -44,15 +41,10 @@ restart() {
} }
case "$1" in case "$1" in
start) start|stop|restart)
start "$1" ;;
;; reload)
stop) restart ;;
stop
;;
restart|reload)
restart
;;
*) *)
echo "Usage: $0 {start|stop|restart}" echo "Usage: $0 {start|stop|restart}"
exit 1 exit 1

View File

@ -14,8 +14,7 @@ start() {
printf 'Starting %s: ' "$DAEMON" printf 'Starting %s: ' "$DAEMON"
[ -f /usr/sbin/$DAEMON ] || echo -en "DISABLED, " [ -f /usr/sbin/$DAEMON ] || echo -en "DISABLED, "
# shellcheck disable=SC2086 # we need the word splitting # shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \ start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $SNMPD_ARGS
-- $SNMPD_ARGS
status=$? status=$?
if [ "$status" -eq 0 ]; then if [ "$status" -eq 0 ]; then
echo "OK" echo "OK"
@ -47,10 +46,9 @@ restart() {
case "$1" in case "$1" in
start|stop|restart) start|stop|restart)
"$1";; "$1" ;;
reload) reload)
# Restart, since there is no true "reload" feature. restart ;;
restart;;
*) *)
echo "Usage: $0 {start|stop|restart|reload}" echo "Usage: $0 {start|stop|restart|reload}"
exit 1 exit 1

View File

@ -9,30 +9,22 @@ TELNETD_ARGS="-F -p 4321 -l /bin/sh"
start() { start() {
printf "Starting telnetd: " printf "Starting telnetd: "
[ -f /usr/sbin/telnetd ] || echo -en "DISABLED, " [ -f /usr/sbin/telnetd ] || echo -en "DISABLED, "
start-stop-daemon -S -q -m -b -p /var/run/telnetd.pid \ start-stop-daemon -S -q -m -b -p /var/run/telnetd.pid -x /usr/sbin/telnetd -- $TELNETD_ARGS
-x /usr/sbin/telnetd -- $TELNETD_ARGS
[ $? = 0 ] && echo "OK" || echo "FAIL" [ $? = 0 ] && echo "OK" || echo "FAIL"
} }
stop() { stop() {
printf "Stopping telnetd: " printf "Stopping telnetd: "
[ -f /usr/sbin/telnetd ] || echo -en "DISABLED, " [ -f /usr/sbin/telnetd ] || echo -en "DISABLED, "
start-stop-daemon -K -q -p /var/run/telnetd.pid \ start-stop-daemon -K -q -p /var/run/telnetd.pid -x /usr/sbin/telnetd
-x /usr/sbin/telnetd
[ $? = 0 ] && echo "OK" || echo "FAIL" [ $? = 0 ] && echo "OK" || echo "FAIL"
} }
case "$1" in case "$1" in
start) start|stop)
start "$1" ;;
;;
stop)
stop
;;
restart|reload) restart|reload)
stop stop; start ;;
start
;;
*) *)
echo "Usage: $0 {start|stop|restart}" echo "Usage: $0 {start|stop|restart}"
exit 1 exit 1

View File

@ -14,8 +14,7 @@ start() {
printf 'Starting %s: ' "$DAEMON" printf 'Starting %s: ' "$DAEMON"
[ -f /usr/sbin/$DAEMON ] || echo -en "DISABLED, " [ -f /usr/sbin/$DAEMON ] || echo -en "DISABLED, "
# shellcheck disable=SC2086 # we need the word splitting # shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \ start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $CROND_ARGS
-- $CROND_ARGS
status=$? status=$?
if [ "$status" -eq 0 ]; then if [ "$status" -eq 0 ]; then
echo "OK" echo "OK"
@ -47,10 +46,9 @@ restart() {
case "$1" in case "$1" in
start|stop|restart) start|stop|restart)
"$1";; "$1" ;;
reload) reload)
# Restart, since there is no true "reload" feature. restart ;;
restart;;
*) *)
echo "Usage: $0 {start|stop|restart|reload}" echo "Usage: $0 {start|stop|restart|reload}"
exit 1 exit 1

View File

@ -1,34 +1,23 @@
#!/bin/sh #!/bin/sh
# You don't usually need to touch this file at all, the full configuration # Configuration of the bridge should be done in /etc/network/interfaces.d/bridgeX
# of the bridge can be done in a standard way on /etc/network/interfaces. # Read more at https://wiki.debian.org/BridgeNetworkConnections
# Have a look at /usr/share/doc/bridge-utils/README.Debian.gz if you want [ ! -x /usr/sbin/brctl ] && exit 0
# more info about the way on wich a bridge is set up on Debian.
if [ ! -x /usr/sbin/brctl ]
then
exit 0
fi
case "$IF_BRIDGE_PORTS" in case "$IF_BRIDGE_PORTS" in
"") "")
exit 0 exit 0 ;;
;;
none) none)
INTERFACES="" INTERFACES="" ;;
;;
all) all)
INTERFACES=`grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/'` INTERFACES=$(grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/') ;;
;;
*) *)
INTERFACES="$IF_BRIDGE_PORTS" INTERFACES="$IF_BRIDGE_PORTS" ;;
;;
esac esac
brctl delbr $IFACE brctl delbr $IFACE
for i in $INTERFACES for i in $INTERFACES; do
do
ip link set $i down ip link set $i down
done done

View File

@ -1,12 +1,6 @@
#!/bin/sh #!/bin/sh
if [ -z "$IF_VLAN_RAW_DEVICE" ] && [ -z "`echo $IFACE | grep '.\+\.[0-9]\+$'`" ] [ -z "$IF_VLAN_RAW_DEVICE" ] && [ -z "$(echo $IFACE | grep '.\+\.[0-9]\+$')" ] && exit 0
then [ ! -x /sbin/vconfig ] && exit 0
exit 0
fi
if [ ! -x /sbin/vconfig ]
then
exit 0
fi
vconfig rem $IFACE vconfig rem $IFACE

View File

@ -1,38 +1,25 @@
#!/bin/sh #!/bin/sh
# You don't usually need to touch this file at all, the full configuration # Configuration of the bridge should be done in /etc/network/interfaces.d/bridgeX
# of the bridge can be done in a standard way on /etc/network/interfaces. # Read more at https://wiki.debian.org/BridgeNetworkConnections
# Have a look at /usr/share/doc/bridge-utils/README.Debian.gz if you want [ ! -x /usr/sbin/brctl ] && exit 0
# more info about the way on wich a bridge is set up on Debian.
if [ ! -x /usr/sbin/brctl ]
then
exit 0
fi
case "$IF_BRIDGE_PORTS" in case "$IF_BRIDGE_PORTS" in
"") "")
exit 0 exit 0 ;;
;;
none) none)
INTERFACES="" INTERFACES="" ;;
;;
all) all)
INTERFACES=`grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/'` INTERFACES=$(grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/') ;;
;;
*) *)
INTERFACES="$IF_BRIDGE_PORTS" INTERFACES="$IF_BRIDGE_PORTS" ;;
;;
esac esac
brctl addbr $IFACE && brctl addbr $IFACE &&
for i in $INTERFACES for i in $INTERFACES; do
do [ -x /etc/network/if-pre-up.d/vlan ] && env IFACE=$i /etc/network/if-pre-up.d/vlan
if [ -x /etc/network/if-pre-up.d/vlan ]; then
env IFACE=$i /etc/network/if-pre-up.d/vlan
fi
brctl addif $IFACE $i && ip link set dev $i up brctl addif $IFACE $i && ip link set dev $i up
done done

View File

@ -5,34 +5,29 @@
case "$IFACE" in case "$IFACE" in
vlan0*) vlan0*)
vconfig set_name_type VLAN_PLUS_VID vconfig set_name_type VLAN_PLUS_VID
VLANID=`echo $IFACE|sed "s/vlan0*//"` VLANID=$(echo $IFACE|sed "s/vlan0*//")
;; ;;
vlan*) vlan*)
vconfig set_name_type VLAN_PLUS_VID_NO_PAD vconfig set_name_type VLAN_PLUS_VID_NO_PAD
VLANID=`echo $IFACE|sed "s/vlan*//"` VLANID=$(echo $IFACE|sed "s/vlan*//")
;; ;;
*.0*) *.0*)
vconfig set_name_type DEV_PLUS_VID vconfig set_name_type DEV_PLUS_VID
VLANID=`echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g"` VLANID=$(echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g")
IF_VLAN_RAW_DEVICE=`echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/"` IF_VLAN_RAW_DEVICE=$(echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/")
;; ;;
*.*) *.*)
vconfig set_name_type DEV_PLUS_VID_NO_PAD vconfig set_name_type DEV_PLUS_VID_NO_PAD
VLANID=`echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g"` VLANID=$(echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g")
IF_VLAN_RAW_DEVICE=`echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/"` IF_VLAN_RAW_DEVICE=$(echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/")
;;
*) exit 0
;; ;;
*)
exit 0
esac esac
if [ -n "$IF_VLAN_RAW_DEVICE" ] if [ -n "$IF_VLAN_RAW_DEVICE" ]; then
then [ ! -x /sbin/vconfig ] && exit 0
if [ ! -x /sbin/vconfig ] if ! ip link show dev "$IF_VLAN_RAW_DEVICE" > /dev/null; then
then
exit 0
fi
if ! ip link show dev "$IF_VLAN_RAW_DEVICE" > /dev/null
then
echo "$IF_VLAN_RAW_DEVICE does not exist, unable to create $IFACE" echo "$IF_VLAN_RAW_DEVICE does not exist, unable to create $IFACE"
exit 1 exit 1
fi fi
@ -43,7 +38,4 @@ fi
ip link set qlen 1000 dev $IFACE ip link set qlen 1000 dev $IFACE
# This is not vlan specific, and should actually go somewhere else. # This is not vlan specific, and should actually go somewhere else.
if [ -n "$IF_HW_MAC_ADDRESS" ] [ -n "$IF_HW_MAC_ADDRESS" ] && ip link set $IFACE address $IF_HW_MAC_ADDRESS
then
ip link set $IFACE address $IF_HW_MAC_ADDRESS
fi

View File

@ -1,4 +1,3 @@
iface eth0:1 inet static iface eth0:1 inet static
address $(fw_printenv -n ipaddr || echo 192.168.1.10) address $(fw_printenv -n ipaddr || echo 192.168.1.10)
netmask 255.255.255.0 netmask 255.255.255.0

View File

@ -12,7 +12,7 @@ if [ "$PS1" ]; then
echo_c 32 "$(printf "%56s" "${GITHUB_VERSION}")" echo_c 32 "$(printf "%56s" "${GITHUB_VERSION}")"
[ -f /etc/openipc_donors ] && echo_c 37 "\n\n$(cat /etc/openipc_donors)\n\n" [ -f /etc/openipc_donors ] && echo_c 37 "\n\n$(cat /etc/openipc_donors)\n\n"
# #
if [ "`id -u`" -eq 0 ]; then if [ "$(id -u)" -eq 0 ]; then
export PS1='\u@\h:\w\# ' export PS1='\u@\h:\w\# '
else else
export PS1='\u@\h:\w\$ ' export PS1='\u@\h:\w\$ '

View File

@ -9,16 +9,14 @@
TOKEN="4938561407:AAGcMIK1zBFW40AT5436vPvEUsFP6BmxhI" TOKEN="4938561407:AAGcMIK1zBFW40AT5436vPvEUsFP6BmxhI"
RUPOR="-10013071148102" RUPOR="-10013071148102"
SDATE=$(date "+%Y-%m-%d %H:%M:%S") SDATE=$(date "+%Y-%m-%d %H:%M:%S")
ALARM=`echo -e "\xE2\x98\x8E K-Telecom"` ALARM=$(echo -e "\xE2\x98\x8E K-Telecom")
STAMP=$(date -u +%s) STAMP=$(date -u +%s)
NOMER=$(echo $1 | tr -d '+') NOMER=$(echo $1 | tr -d '+')
send() { send() {
# #
if [ -z "${NOMER}" ] ; then [ -z "${NOMER}" ] && NOMER="anonymouse"
NOMER="anonymouse"
fi
# #
curl -k -o - --connect-timeout 30 --max-time 30 -X POST \ curl -k -o - --connect-timeout 30 --max-time 30 -X POST \
https://api.telegram.org/bot${TOKEN}/sendMessage -d chat_id="${RUPOR}" -d disable_notification="true" -d text="${ALARM} ${NOMER} | ${SDATE}" >/dev/null 2>&1 https://api.telegram.org/bot${TOKEN}/sendMessage -d chat_id="${RUPOR}" -d disable_notification="true" -d text="${ALARM} ${NOMER} | ${SDATE}" >/dev/null 2>&1
@ -28,4 +26,3 @@ send() {
} }
send send