mirror of https://github.com/OpenIPC/firmware.git
format scripts with tabs, replace backticks, refactor (#770)
parent
ca3fffe5cd
commit
a6b9d985f4
|
@ -13,8 +13,7 @@ SYSLOGD_ARGS="-C64 -t"
|
|||
start() {
|
||||
printf 'Starting %s: ' "$DAEMON"
|
||||
# shellcheck disable=SC2086 # we need the word splitting
|
||||
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" \
|
||||
-- -n $SYSLOGD_ARGS
|
||||
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" -- -n $SYSLOGD_ARGS
|
||||
status=$?
|
||||
if [ "$status" -eq 0 ]; then
|
||||
echo "OK"
|
||||
|
@ -45,10 +44,10 @@ restart() {
|
|||
|
||||
case "$1" in
|
||||
start|stop|restart)
|
||||
"$1";;
|
||||
"$1" ;;
|
||||
reload)
|
||||
# Restart, since there is no true "reload" feature.
|
||||
restart;;
|
||||
restart ;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload}"
|
||||
exit 1
|
||||
|
|
|
@ -31,18 +31,11 @@ stop()
|
|||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
start|stop)
|
||||
"$1" ;;
|
||||
restart|reload)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
stop; start ;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
case "$1" in
|
||||
start)
|
||||
echo "Starting mdev..."
|
||||
# echo /sbin/mdev >/proc/sys/kernel/hotplug
|
||||
echo /sbin/mdev >/proc/sys/kernel/hotplug
|
||||
/sbin/mdev -s
|
||||
;;
|
||||
stop)
|
||||
|
|
|
@ -13,8 +13,7 @@ NTPD_ARGS="-n"
|
|||
start() {
|
||||
printf 'Starting %s: ' "$DAEMON"
|
||||
# shellcheck disable=SC2086 # we need the word splitting
|
||||
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
|
||||
-- $NTPD_ARGS
|
||||
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $NTPD_ARGS
|
||||
status=$?
|
||||
if [ "$status" -eq 0 ]; then
|
||||
echo "OK"
|
||||
|
@ -45,10 +44,9 @@ restart() {
|
|||
|
||||
case "$1" in
|
||||
start|stop|restart)
|
||||
"$1";;
|
||||
"$1" ;;
|
||||
reload)
|
||||
# Restart, since there is no true "reload" feature.
|
||||
restart;;
|
||||
restart ;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload}"
|
||||
exit 1
|
||||
|
|
|
@ -14,9 +14,7 @@ start() {
|
|||
# create the directory pointed to by the symlink.
|
||||
# - the filesystem is RW (i.e. we can rm the symlink),
|
||||
# replace the symlink with an actual directory
|
||||
if [ -L /etc/dropbear \
|
||||
-a "$(readlink /etc/dropbear)" = "/var/run/dropbear" ]
|
||||
then
|
||||
if [ -L /etc/dropbear -a "$(readlink /etc/dropbear)" = "/var/run/dropbear" ]; then
|
||||
if rm -f /etc/dropbear >/dev/null 2>&1; then
|
||||
mkdir -p /etc/dropbear
|
||||
else
|
||||
|
@ -29,8 +27,7 @@ start() {
|
|||
printf "Starting dropbear sshd: "
|
||||
umask 077
|
||||
|
||||
start-stop-daemon -S -q -p /var/run/dropbear.pid \
|
||||
--exec /usr/sbin/dropbear -- $DROPBEAR_ARGS
|
||||
start-stop-daemon -S -q -p /var/run/dropbear.pid --exec /usr/sbin/dropbear -- $DROPBEAR_ARGS
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
}
|
||||
stop() {
|
||||
|
@ -44,15 +41,10 @@ restart() {
|
|||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|reload)
|
||||
restart
|
||||
;;
|
||||
start|stop|restart)
|
||||
"$1" ;;
|
||||
reload)
|
||||
restart ;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
|
|
|
@ -14,8 +14,7 @@ start() {
|
|||
printf 'Starting %s: ' "$DAEMON"
|
||||
[ -f /usr/sbin/$DAEMON ] || echo -en "DISABLED, "
|
||||
# shellcheck disable=SC2086 # we need the word splitting
|
||||
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
|
||||
-- $SNMPD_ARGS
|
||||
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $SNMPD_ARGS
|
||||
status=$?
|
||||
if [ "$status" -eq 0 ]; then
|
||||
echo "OK"
|
||||
|
@ -47,10 +46,9 @@ restart() {
|
|||
|
||||
case "$1" in
|
||||
start|stop|restart)
|
||||
"$1";;
|
||||
"$1" ;;
|
||||
reload)
|
||||
# Restart, since there is no true "reload" feature.
|
||||
restart;;
|
||||
restart ;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload}"
|
||||
exit 1
|
||||
|
|
|
@ -9,30 +9,22 @@ TELNETD_ARGS="-F -p 4321 -l /bin/sh"
|
|||
start() {
|
||||
printf "Starting telnetd: "
|
||||
[ -f /usr/sbin/telnetd ] || echo -en "DISABLED, "
|
||||
start-stop-daemon -S -q -m -b -p /var/run/telnetd.pid \
|
||||
-x /usr/sbin/telnetd -- $TELNETD_ARGS
|
||||
start-stop-daemon -S -q -m -b -p /var/run/telnetd.pid -x /usr/sbin/telnetd -- $TELNETD_ARGS
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
}
|
||||
|
||||
stop() {
|
||||
printf "Stopping telnetd: "
|
||||
[ -f /usr/sbin/telnetd ] || echo -en "DISABLED, "
|
||||
start-stop-daemon -K -q -p /var/run/telnetd.pid \
|
||||
-x /usr/sbin/telnetd
|
||||
start-stop-daemon -K -q -p /var/run/telnetd.pid -x /usr/sbin/telnetd
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
start|stop)
|
||||
"$1" ;;
|
||||
restart|reload)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
stop; start ;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
|
|
|
@ -14,8 +14,7 @@ start() {
|
|||
printf 'Starting %s: ' "$DAEMON"
|
||||
[ -f /usr/sbin/$DAEMON ] || echo -en "DISABLED, "
|
||||
# shellcheck disable=SC2086 # we need the word splitting
|
||||
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
|
||||
-- $CROND_ARGS
|
||||
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $CROND_ARGS
|
||||
status=$?
|
||||
if [ "$status" -eq 0 ]; then
|
||||
echo "OK"
|
||||
|
@ -47,10 +46,9 @@ restart() {
|
|||
|
||||
case "$1" in
|
||||
start|stop|restart)
|
||||
"$1";;
|
||||
"$1" ;;
|
||||
reload)
|
||||
# Restart, since there is no true "reload" feature.
|
||||
restart;;
|
||||
restart ;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload}"
|
||||
exit 1
|
||||
|
|
|
@ -1,34 +1,23 @@
|
|||
#!/bin/sh
|
||||
|
||||
# You don't usually need to touch this file at all, the full configuration
|
||||
# of the bridge can be done in a standard way on /etc/network/interfaces.
|
||||
# Configuration of the bridge should be done in /etc/network/interfaces.d/bridgeX
|
||||
# Read more at https://wiki.debian.org/BridgeNetworkConnections
|
||||
|
||||
# Have a look at /usr/share/doc/bridge-utils/README.Debian.gz if you want
|
||||
# more info about the way on wich a bridge is set up on Debian.
|
||||
|
||||
if [ ! -x /usr/sbin/brctl ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
[ ! -x /usr/sbin/brctl ] && exit 0
|
||||
|
||||
case "$IF_BRIDGE_PORTS" in
|
||||
"")
|
||||
exit 0
|
||||
;;
|
||||
exit 0 ;;
|
||||
none)
|
||||
INTERFACES=""
|
||||
;;
|
||||
INTERFACES="" ;;
|
||||
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
|
||||
|
||||
brctl delbr $IFACE
|
||||
|
||||
for i in $INTERFACES
|
||||
do
|
||||
for i in $INTERFACES; do
|
||||
ip link set $i down
|
||||
done
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -z "$IF_VLAN_RAW_DEVICE" ] && [ -z "`echo $IFACE | grep '.\+\.[0-9]\+$'`" ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
if [ ! -x /sbin/vconfig ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
[ -z "$IF_VLAN_RAW_DEVICE" ] && [ -z "$(echo $IFACE | grep '.\+\.[0-9]\+$')" ] && exit 0
|
||||
[ ! -x /sbin/vconfig ] && exit 0
|
||||
|
||||
vconfig rem $IFACE
|
||||
|
|
|
@ -1,38 +1,25 @@
|
|||
#!/bin/sh
|
||||
|
||||
# You don't usually need to touch this file at all, the full configuration
|
||||
# of the bridge can be done in a standard way on /etc/network/interfaces.
|
||||
# Configuration of the bridge should be done in /etc/network/interfaces.d/bridgeX
|
||||
# Read more at https://wiki.debian.org/BridgeNetworkConnections
|
||||
|
||||
# Have a look at /usr/share/doc/bridge-utils/README.Debian.gz if you want
|
||||
# more info about the way on wich a bridge is set up on Debian.
|
||||
|
||||
if [ ! -x /usr/sbin/brctl ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
[ ! -x /usr/sbin/brctl ] && exit 0
|
||||
|
||||
case "$IF_BRIDGE_PORTS" in
|
||||
"")
|
||||
exit 0
|
||||
;;
|
||||
exit 0 ;;
|
||||
none)
|
||||
INTERFACES=""
|
||||
;;
|
||||
INTERFACES="" ;;
|
||||
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
|
||||
|
||||
brctl addbr $IFACE &&
|
||||
|
||||
for i in $INTERFACES
|
||||
do
|
||||
if [ -x /etc/network/if-pre-up.d/vlan ]; then
|
||||
env IFACE=$i /etc/network/if-pre-up.d/vlan
|
||||
fi
|
||||
for i in $INTERFACES; do
|
||||
[ -x /etc/network/if-pre-up.d/vlan ] && env IFACE=$i /etc/network/if-pre-up.d/vlan
|
||||
brctl addif $IFACE $i && ip link set dev $i up
|
||||
done
|
||||
|
||||
|
|
|
@ -5,34 +5,29 @@
|
|||
case "$IFACE" in
|
||||
vlan0*)
|
||||
vconfig set_name_type VLAN_PLUS_VID
|
||||
VLANID=`echo $IFACE|sed "s/vlan0*//"`
|
||||
VLANID=$(echo $IFACE|sed "s/vlan0*//")
|
||||
;;
|
||||
vlan*)
|
||||
vconfig set_name_type VLAN_PLUS_VID_NO_PAD
|
||||
VLANID=`echo $IFACE|sed "s/vlan*//"`
|
||||
VLANID=$(echo $IFACE|sed "s/vlan*//")
|
||||
;;
|
||||
*.0*)
|
||||
vconfig set_name_type DEV_PLUS_VID
|
||||
VLANID=`echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g"`
|
||||
IF_VLAN_RAW_DEVICE=`echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/"`
|
||||
VLANID=$(echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g")
|
||||
IF_VLAN_RAW_DEVICE=$(echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/")
|
||||
;;
|
||||
*.*)
|
||||
vconfig set_name_type DEV_PLUS_VID_NO_PAD
|
||||
VLANID=`echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g"`
|
||||
IF_VLAN_RAW_DEVICE=`echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/"`
|
||||
;;
|
||||
*) exit 0
|
||||
VLANID=$(echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g")
|
||||
IF_VLAN_RAW_DEVICE=$(echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/")
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
esac
|
||||
|
||||
if [ -n "$IF_VLAN_RAW_DEVICE" ]
|
||||
then
|
||||
if [ ! -x /sbin/vconfig ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
if ! ip link show dev "$IF_VLAN_RAW_DEVICE" > /dev/null
|
||||
then
|
||||
if [ -n "$IF_VLAN_RAW_DEVICE" ]; then
|
||||
[ ! -x /sbin/vconfig ] && exit 0
|
||||
if ! ip link show dev "$IF_VLAN_RAW_DEVICE" > /dev/null; then
|
||||
echo "$IF_VLAN_RAW_DEVICE does not exist, unable to create $IFACE"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -43,7 +38,4 @@ fi
|
|||
ip link set qlen 1000 dev $IFACE
|
||||
|
||||
# This is not vlan specific, and should actually go somewhere else.
|
||||
if [ -n "$IF_HW_MAC_ADDRESS" ]
|
||||
then
|
||||
ip link set $IFACE address $IF_HW_MAC_ADDRESS
|
||||
fi
|
||||
[ -n "$IF_HW_MAC_ADDRESS" ] && ip link set $IFACE address $IF_HW_MAC_ADDRESS
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
iface eth0:1 inet static
|
||||
address $(fw_printenv -n ipaddr || echo 192.168.1.10)
|
||||
netmask 255.255.255.0
|
||||
|
|
|
@ -12,7 +12,7 @@ if [ "$PS1" ]; then
|
|||
echo_c 32 "$(printf "%56s" "${GITHUB_VERSION}")"
|
||||
[ -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\# '
|
||||
else
|
||||
export PS1='\u@\h:\w\$ '
|
||||
|
|
|
@ -9,16 +9,14 @@
|
|||
TOKEN="4938561407:AAGcMIK1zBFW40AT5436vPvEUsFP6BmxhI"
|
||||
RUPOR="-10013071148102"
|
||||
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)
|
||||
NOMER=$(echo $1 | tr -d '+')
|
||||
|
||||
|
||||
send() {
|
||||
#
|
||||
if [ -z "${NOMER}" ] ; then
|
||||
NOMER="anonymouse"
|
||||
fi
|
||||
[ -z "${NOMER}" ] && NOMER="anonymouse"
|
||||
#
|
||||
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
|
||||
|
@ -28,4 +26,3 @@ send() {
|
|||
}
|
||||
|
||||
send
|
||||
|
||||
|
|
Loading…
Reference in New Issue