aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-11-05 15:56:27 +0100
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-11-05 16:01:57 +0100
commita8f3360e938b3cfc8b785222be522cdbf83e5692 (patch)
treec791cadc7fc6bb062173e40218ec9fd2749fe3f8 /scripts
parent5923ad488a1eb3c41e07cf598c1251ce07ea6c04 (diff)
Split default init scripts into seperate package
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makemodule.am5
-rw-r--r--scripts/devfs.sh.in21
-rwxr-xr-xscripts/ifcfg.sh.in89
-rw-r--r--scripts/ifdown.sh26
-rwxr-xr-xscripts/ifrename.sh.in65
-rw-r--r--scripts/modules_load.sh.in39
-rwxr-xr-xscripts/setntpdate.sh67
-rw-r--r--scripts/trymount.sh7
8 files changed, 0 insertions, 319 deletions
diff --git a/scripts/Makemodule.am b/scripts/Makemodule.am
deleted file mode 100644
index f29f5f9..0000000
--- a/scripts/Makemodule.am
+++ /dev/null
@@ -1,5 +0,0 @@
-helper_SCRIPTS += scripts/devfs.sh scripts/trymount.sh scripts/ifrename.sh
-helper_SCRIPTS += scripts/ifcfg.sh scripts/ifdown.sh scripts/modules_load.sh
-helper_SCRIPTS += scripts/setntpdate.sh
-
-EXTRA_DIST += scripts/trymount.sh scripts/ifdown.sh scripts/setntpdate.sh
diff --git a/scripts/devfs.sh.in b/scripts/devfs.sh.in
deleted file mode 100644
index af002f6..0000000
--- a/scripts/devfs.sh.in
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-mount -t devtmpfs none /dev
-
-[ -c /dev/console ] || mknod -m 600 /dev/console c 5 1
-[ -c /dev/tty ] || mknod -m 666 /dev/tty c 5 0
-[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3
-[ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11
-[ -e /dev/fd ] || ln -snf /proc/self/fd /dev/fd
-[ -e /dev/stdin ] || ln -snf /proc/self/fd/0 /dev/stdin
-[ -e /dev/stdout ] || ln -snf /proc/self/fd/1 /dev/stdout
-[ -e /dev/stderr ] || ln -snf /proc/self/fd/2 /dev/stderr
-[ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core
-
-mkdir -p /dev/mqueue -m 1777
-mkdir -p /dev/pts -m 0755
-mkdir -p /dev/shm -m 1777
-
-@SCRIPTDIR@/trymount.sh "/dev/mqueue" "mqueue" "noexec,nosuid,nodev"
-@SCRIPTDIR@/trymount.sh "/dev/pts" "devpts" "noexec,nosuid,gid=5,mode=0620"
-@SCRIPTDIR@/trymount.sh "/dev/shm" "tmpfs" "noexec,nosuid,nodev,mode=1777"
diff --git a/scripts/ifcfg.sh.in b/scripts/ifcfg.sh.in
deleted file mode 100755
index 8f684e7..0000000
--- a/scripts/ifcfg.sh.in
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/bin/sh
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-# Copyright (C) 2018 - David Oberhollenzer
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <https://www.gnu.org/licenses/>.
-#
-CFGPATH="@ETCPATH@/netcfg"
-
-[ -d "$CFGPATH" ] || exit 0
-
-# configure interfaces
-for IFPATH in /sys/class/net/*; do
- [ "$IFPATH" == "/sys/class/net/lo" ] && continue
-
- IF=`basename $IFPATH`
- CFGFILE="$CFGPATH/$IF"
-
- [ -f "$CFGFILE" ] || continue
-
- ip link set dev "$IF" down
-
- while read LINE;
- do
- trimmed=`echo -- $LINE`
- [ ! -z "$trimmed" ] || continue
- set $trimmed
-
- case "$1" in
- address|addr|ip|ip6|ipv6)
- shift
- ip address add $@ dev "$IF"
- ;;
- arp|multicast|mtu)
- ip link set dev "$IF" $@
- ;;
- offload)
- shift
- ethtool -K "$IF" $@
- ;;
- *)
- ;;
- esac
- done < "$CFGFILE"
-done
-
-# configure static routs
-if [ -f "$CFGPATH/routes" ]; then
- while read LINE;
- do
- trimmed=`echo -- $LINE`
- [ ! -z "$trimmed" ] || continue
- set $trimmed
-
- case "$1" in
- route)
- shift
- ip route add $@
- ;;
- rule)
- shift
- ip rule add $@
- ;;
- *)
- ;;
- esac
- done < "$CFGFILE"
-fi
-
-# activate interfaces
-for IFPATH in /sys/class/net/*; do
- [ "$IFPATH" == "/sys/class/net/lo" ] && continue
-
- IF=`basename $IFPATH`
-
- [ ! -f "$CFGPATH/$IF" ] || ip link set dev "$IF" up
-done
diff --git a/scripts/ifdown.sh b/scripts/ifdown.sh
deleted file mode 100644
index 2e2b30e..0000000
--- a/scripts/ifdown.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-# Copyright (C) 2018 - David Oberhollenzer
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <https://www.gnu.org/licenses/>.
-#
-for IFPATH in /sys/class/net/*; do
- [ "$IFPATH" == "/sys/class/net/lo" ] && continue
-
- IF=`basename $IFPATH`
-
- ip link set dev "$IF" down
-done
diff --git a/scripts/ifrename.sh.in b/scripts/ifrename.sh.in
deleted file mode 100755
index fee5444..0000000
--- a/scripts/ifrename.sh.in
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/bin/sh
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-# Copyright (C) 2018 - David Oberhollenzer
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <https://www.gnu.org/licenses/>.
-#
-NAMERULES="@ETCPATH@/netcfg/ifrename"
-TMPPATH="/tmp/ifrename"
-
-[ -f "$NAMERULES" ] || exit 0
-
-mkdir -p "$TMPPATH"
-
-for IFPATH in /sys/class/net/*; do
- [ "$IFPATH" == "/sys/class/net/lo" ] && continue
-
- IF=`basename $IFPATH`
- MAC=`cat $IFPATH/address`
-
- grep "^[^,]\+,[^,]\+,[a-zA-Z0-9]\+$" $NAMERULES | while read LINE;
- do
- NAMECMP=$(echo $LINE | cut -d',' -f1)
- ADDRCMP=$(echo $LINE | cut -d',' -f2)
- RULE=$(echo $LINE | cut -d',' -f3)
-
- case $IF in ($NAMECMP) ;; *) continue;; esac
- case $MAC in ($ADDRCMP) ;; *) continue;; esac
-
- echo "$MAC,$IF" >> "$TMPPATH/$RULE"
- break
- done
-done
-
-for FNAME in $TMPPATH/*; do
- [ ! -f "$FNAME" ] && break
-
- IDX=0
- PREFIX=$(basename $FNAME)
-
- sort -t',' -k1 -u $FNAME | while read LINE;
- do
- OLDNAME=$(echo $LINE | cut -d',' -f2)
- NEWNAME="$PREFIX$IDX"
- IDX=`expr $IDX + 1`
-
- ip link set "$OLDNAME" name "$NEWNAME"
- done
-
- rm "$FNAME"
-done
-
-rmdir "$TMPPATH"
diff --git a/scripts/modules_load.sh.in b/scripts/modules_load.sh.in
deleted file mode 100644
index 518228c..0000000
--- a/scripts/modules_load.sh.in
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/sh
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-# Copyright (C) 2018 - David Oberhollenzer
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <https://www.gnu.org/licenses/>.
-#
-MODLIST="@ETCPATH@/modules"
-
-if [ ! -f "$MODLIST" ]; then
- exit 0
-fi
-
-while read LINE;
-do
- trimmed=`echo -- $LINE`
- [ ! -z "$trimmed" ] || continue
- set $trimmed
-
- case "$1" in
- \#*)
- ;;
- *)
- modprobe "$1"
- ;;
- esac
-done < "$MODLIST"
diff --git a/scripts/setntpdate.sh b/scripts/setntpdate.sh
deleted file mode 100755
index c0ed1b4..0000000
--- a/scripts/setntpdate.sh
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/sh
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-# Copyright (C) 2018 - David Oberhollenzer
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <https://www.gnu.org/licenses/>.
-#
-
-resolve() {
- local domain="$1"
- local server="$2"
-
- if [ -x "$(command -v dig)" ]; then
- if [ -z "$server" ]; then
- dig +short "$domain"
- else
- dig +short "@$server" "$domain"
- fi
- return $?
- fi
-
- if [ -x "$(command -v drill)" ]; then
- if [ -z "$server" ]; then
- drill "$domain" | grep "^${domain}." | cut -d$'\t' -f5
- else
- drill "@$server" "$domain" | grep "^${domain}." |\
- cut -d$'\t' -f5
- fi
- return $?
- fi
- exit 1
-}
-
-try_update() {
- while read ip; do
- if ntpdate -bu "$ip"; then
- return 0
- fi
- done
-
- return 1
-}
-
-pool="pool.ntp.org"
-dns="1.1.1.1"
-
-# try default DNS server first
-resolve "$pool" "" | try_update
-[ $? -eq 0 ] && exit 0
-
-# try fallback public dns server
-ping -q -c 1 "$dns" || exit 1
-
-resolve "$pool" "$dns" | try_update
-exit $?
diff --git a/scripts/trymount.sh b/scripts/trymount.sh
deleted file mode 100644
index 9be77f6..0000000
--- a/scripts/trymount.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-if [ -d "$1" ]; then
- if grep -qsE "[[:space:]]+$2$" "/proc/filesystems"; then
- mount -n -t "$2" -o "$3" "$2" "$1"
- fi
-fi