mirror of
https://github.com/OpenSolo/OpenSolo.git
synced 2025-06-13 13:47:48 +02:00
Initial commit, based on .tar.gz file as provided by 3DR , see SOURCE file
This commit is contained in:
84
sololink/net/etc/init.d/hostapd
Executable file
84
sololink/net/etc/init.d/hostapd
Executable file
@ -0,0 +1,84 @@
|
||||
#!/bin/sh
|
||||
DAEMON=/usr/sbin/hostapd
|
||||
NAME=hostapd
|
||||
DESC="HOSTAP Daemon"
|
||||
HOSTAPD_CONF="/etc/hostapd.conf"
|
||||
HOSTAPD_BACK="/etc/hostapd.back"
|
||||
ARGS="/etc/hostapd.conf -B"
|
||||
SOLO_CONF="/etc/sololink.conf"
|
||||
|
||||
test -f $DAEMON || exit 0
|
||||
|
||||
set -e
|
||||
|
||||
# Return true if parameter ($2) in config file ($1) is "True"
|
||||
isEnabled() {
|
||||
grep -i -q "[[:space:]]*$2[[:space:]]*=[[:space:]]*True" $1
|
||||
}
|
||||
|
||||
# Return true if the SSID in hostapd.conf is still the default
|
||||
isDefault() {
|
||||
grep -i -q "^ssid=SoloLink_Default" $1
|
||||
}
|
||||
|
||||
#Return the country code we should be using
|
||||
getCountryCode() {
|
||||
mkdir -p /tmp/bootmnt
|
||||
mount /dev/mmcblk0p1 /tmp/bootmnt -o ro
|
||||
if [ ! -e /tmp/bootmnt/.reg ]; then
|
||||
echo "US"
|
||||
else
|
||||
cat /tmp/bootmnt/.reg
|
||||
fi
|
||||
umount /tmp/bootmnt
|
||||
rm -rf /tmp/bootmnt
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
# If the 3dr config file does not exist, or if it does and ApEnable
|
||||
# is True, start hostapd
|
||||
if [ ! -f $SOLO_CONF ] || isEnabled $SOLO_CONF ApEnable; then
|
||||
echo -n "Starting $DESC: "
|
||||
# back up hostapd.conf
|
||||
cp ${HOSTAPD_CONF} ${HOSTAPD_BACK}
|
||||
md5sum ${HOSTAPD_BACK} > ${HOSTAPD_BACK}.md5
|
||||
sync
|
||||
# Unique-ize the SSID if it has not been done
|
||||
if isDefault ${HOSTAPD_CONF}; then
|
||||
# update SSID
|
||||
/usr/bin/hostapdconfig.py --ssid SoloLink_ --ssidmac wlan0-ap
|
||||
# initialize regulatory domain
|
||||
/usr/bin/hostapdconfig.py --country `getCountryCode`
|
||||
fi
|
||||
# set channel to that of wlan0 if it is associated
|
||||
/usr/bin/hostapdconfig.py --channel wlan0
|
||||
md5sum ${HOSTAPD_CONF} > ${HOSTAPD_CONF}.md5
|
||||
sync
|
||||
rm ${HOSTAPD_BACK} ${HOSTAPD_BACK}.md5
|
||||
sync
|
||||
start-stop-daemon -S -x $DAEMON -- $ARGS
|
||||
echo "$NAME."
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping $DESC: "
|
||||
start-stop-daemon -K -x $DAEMON
|
||||
echo "$NAME."
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
reload)
|
||||
echo -n "Reloading $DESC: "
|
||||
killall -HUP $(basename ${DAEMON})
|
||||
echo "$NAME."
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
25
sololink/net/etc/init.d/netinit
Executable file
25
sololink/net/etc/init.d/netinit
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
NAME=wlan0-ap
|
||||
DESC="AP Interface"
|
||||
SOLO_CONF="/etc/sololink.conf"
|
||||
|
||||
# Return true if parameter ($2) in config file ($1) is "True"
|
||||
isEnabled() {
|
||||
grep -i -q "[[:space:]]*$2[[:space:]]*=[[:space:]]*True" $1
|
||||
}
|
||||
|
||||
# wlan0 exists only if the PCIe phy initialized
|
||||
# wlan0-ap never exists at this point (this is where we create it)
|
||||
if [ -e /sys/class/net/wlan0 ]; then
|
||||
# If the 3dr config file does not exist, or if it does and ApEnable is True,
|
||||
# set up the wlan0-ap interface
|
||||
if [ ! -f $SOLO_CONF ] || isEnabled $SOLO_CONF ApEnable; then
|
||||
echo -n "Initializing $DESC: "
|
||||
iw phy phy0 interface add $NAME type __ap
|
||||
ip link set dev $NAME address `/usr/bin/getmaclocal.py wlan0`
|
||||
echo "$NAME."
|
||||
fi
|
||||
else
|
||||
echo "wlan0 does not exist"
|
||||
fi
|
117
sololink/net/etc/init.d/networking
Executable file
117
sololink/net/etc/init.d/networking
Executable file
@ -0,0 +1,117 @@
|
||||
#!/bin/sh -e
|
||||
### BEGIN INIT INFO
|
||||
# Provides: networking
|
||||
# Required-Start: mountvirtfs $local_fs
|
||||
# Required-Stop: $local_fs
|
||||
# Should-Start: ifupdown
|
||||
# Should-Stop: ifupdown
|
||||
# Default-Start: S
|
||||
# Default-Stop: 0 6
|
||||
# Short-Description: Raise network interfaces.
|
||||
### END INIT INFO
|
||||
|
||||
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
CONF="/etc/sololink.conf"
|
||||
|
||||
[ -x /sbin/ifup ] || exit 0
|
||||
|
||||
check_network_file_systems() {
|
||||
[ -e /proc/mounts ] || return 0
|
||||
|
||||
if [ -e /etc/iscsi/iscsi.initramfs ]; then
|
||||
echo "not deconfiguring network interfaces: iSCSI root is mounted."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exec 9<&0 < /proc/mounts
|
||||
while read DEV MTPT FSTYPE REST; do
|
||||
case $DEV in
|
||||
/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
|
||||
echo "not deconfiguring network interfaces: network devices still mounted."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
case $FSTYPE in
|
||||
nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs)
|
||||
echo "not deconfiguring network interfaces: network file systems still mounted."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
exec 0<&9 9<&-
|
||||
}
|
||||
|
||||
check_network_swap() {
|
||||
[ -e /proc/swaps ] || return 0
|
||||
|
||||
exec 9<&0 < /proc/swaps
|
||||
while read DEV MTPT FSTYPE REST; do
|
||||
case $DEV in
|
||||
/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
|
||||
echo "not deconfiguring network interfaces: network swap still mounted."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
exec 0<&9 9<&-
|
||||
}
|
||||
|
||||
isEnabled() {
|
||||
grep -i -q "[[:space:]]*$2[[:space:]]*=[[:space:]]*True" $1
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Configuring network interfaces... "
|
||||
sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1
|
||||
# Since we might modprobe -r ath9k in a networking shutdown,
|
||||
# be sure to re-modprobe it at a startup
|
||||
modprobe ath9k
|
||||
ifup -a
|
||||
if [ -e /sys/class/net/wlan0 ]; then
|
||||
# if the config file exists and StationEnable is True, bring up wlan0
|
||||
if [ -f $CONF ] && isEnabled $CONF StationEnable; then
|
||||
ifup wlan0
|
||||
fi
|
||||
else
|
||||
# this should exist on both solo and controller
|
||||
echo -n "(wlan0 does not exist!) "
|
||||
fi
|
||||
if [ -e /sys/class/net/wlan0-ap ]; then
|
||||
# if the config file does not exist, or if it does and ApEnable is
|
||||
# True, bring up wlan0-ap
|
||||
if [ ! -f $CONF ] || isEnabled $CONF ApEnable; then
|
||||
ifup wlan0-ap
|
||||
fi
|
||||
fi
|
||||
echo "done."
|
||||
;;
|
||||
|
||||
stop)
|
||||
check_network_file_systems
|
||||
check_network_swap
|
||||
|
||||
echo -n "Deconfiguring network interfaces... "
|
||||
ifdown wlan0 &> /dev/null
|
||||
ifdown wlan0-ap &> /dev/null
|
||||
ifdown -a
|
||||
echo "done."
|
||||
;;
|
||||
|
||||
force-reload|restart)
|
||||
echo "Running $0 $1 is deprecated because it may not enable again some interfaces"
|
||||
echo "Reconfiguring network interfaces... "
|
||||
# this will restart only the "auto" interfaces (not wlan0 or wlan0-ap)
|
||||
ifdown -a || true
|
||||
ifup -a
|
||||
echo "done."
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: /etc/init.d/networking {start|stop}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
Reference in New Issue
Block a user