Adding wifi scripts; general cleanup

This commit is contained in:
DarkFeather 2017-10-25 23:50:52 -05:00
parent e4afa2e8e5
commit ce9d50ab0c
7 changed files with 58 additions and 14 deletions

View File

@ -1,25 +1,29 @@
LIST=arch-update close-guest fix-sound log-guest open-guest restart-service silent-guardian revproxy simple-web
LIST=arch-update close-guest fix-sound log-guest open-guest restart-service silent-guardian revproxy simple-web wifi wifiboot
LOCATION=/root/bin
INSTALLER != curl -s https://aninix.net/foundation/installer-test.bash | /bin/bash
PERMISSION=0700
compile:
compile: ${LIST} ./wifi.service
@echo Nothing to compile.
install: compile
install: compile
mkdir -p ${LOCATION};
mkdir -p /var/log/aninix/
for i in ${LIST}; do cp ./$$i ${LOCATION}; done
cp ./wifi.service /usr/lib/systemd/system/wifi.service
make checkperm
reverse:
for i in ${LIST}; do cp ${LOCATION}/$$i .; done
cp /usr/lib/systemd/system/wifi.service .
test: ${LIST}
for i in ${LIST}; do [ "$$(grep -c '#/bin/bash' $$i)" -ne 1 ]; done
checkperm:
for i in ${LIST}; do chown root:root ${LOCATION}/$$i; chmod ${PERMISSION} ${LOCATION}/$$i; done
chown root: /usr/lib/systemd/system/wifi.service;
chmod 0644 /usr/lib/systemd/system/wifi.service
clean:
@echo Nothing to do.

16
Admin/wifi Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
if [ -z "$1" ]; then
echo Usage: $0 conf_name '[ interface ]'
exit 1;
else
conf="$1"
fi
if [ -z "$2" ]; then
interface="wlp4s0"
else
interface="$2"
fi
wpa_supplicant -i "$interface" -c /etc/wpa_supplicant/"${conf}".conf -B
sleep 3
dhcpcd "$interface"
exit $?

12
Admin/wifi.service Normal file
View File

@ -0,0 +1,12 @@
[Unit]
Description=Wifi Connectivity Service
Wants=network-online.target
After=network-online.target
[Service]
ExecStart=/root/bin/wifiboot
Type=oneshot
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target

13
Admin/wifiboot Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
MAC="34:f6:4b:36:12:8f"
interface=`ip link list | grep -B 1 "$MAC" | head -n 1 | cut -f 2 -d ':' | cut -f 2 -d ' '`
ip link set "$interface" up
for i in `iwlist "$interface" scanning | grep ESSID | cut -f 2 -d \" | tr '[:upper:]' '[:lower:]'`; do
if [ -f /etc/wpa_supplicant/"$i".conf ]; then
/root/bin/wifi "$i" "$interface"
if [ $? -eq 0 ]; then
exit 0;
fi
fi
done

View File

@ -9,7 +9,7 @@ compile: ./shadowarch
install: compile
for i in ${SYNCLIST}; do rsync -avz -r `echo $$i | sed 's#^/etc/##'` $$i; done
# This is a nicety.
if [ -f /root/shadowarch* ]; then sed -i 's/`uname -o`/ShadowArch/g' /etc/bash.bashrc; fi
if [ -f /root/shadowarch* ]; then sed -i 's/`uname -o`/ShadowArch/g' /etc/bashrc; fi
repository: shadowarch ${HTTPROOT}
cp ./shadowarch ${HTTPROOT}
@ -33,9 +33,9 @@ reverse: ${HTTPROOT}/shadowarch ${SYNCLIST}
clean:
if [ -f /etc/bash.bashrc ]; then printf "Remove /etc/bash.bashrc? [y/n] "; read answer; if [ "$$answer" == "y" ]; then rm /etc/bash.bashrc; fi; fi
diff: ${HTTPROOT}/shadowarch ${SYNCLIST}
diff ./shadowarch ${HTTPROOT}/shadowarch
for i in ${SYNCLIST}; do diff "$$i" ./`echo $$i | rev | cut -f 1 -d '/' | rev` || [ 1 -eq 1 ]; done
diff: ${SYNCLIST}
if [ -f ${HTTPROOT}/shadowarch ]; then diff ./shadowarch ${HTTPROOT}/shadowarch; echo; fi
for i in ${SYNCLIST}; do diff -rc "$$i" ./`echo $$i | rev | cut -f 1 -d '/' | rev`; echo; done
find-missing-hooks-in-src:
@for i in `wget -q -O - https://aninix.net/foundation/ | grep toplevel-repo | cut -f 4 -d \'`; do if [ -z $$i ]; then continue; fi; for file in `find ../.. -type f -name Makefile | grep $$i`; do if [ -z "$$file" ]; then echo NO MAKEFILE FOR $$i; elif [ `grep -c -i 'hook for systemd' $$file` -eq 0 ]; then echo HOOK MISSING IN: $$file; else echo HOOK FOUND IN: $$file; fi; done; done

View File

@ -27,7 +27,6 @@ esac
[ -f /etc/bash.motd ] && cat /etc/bash.motd
### AniNIX Customizations ###
alias get-commands='for i in $( echo $PATH | sed "s/:/\n/g"); do ls $i; done | sort | less'
alias whoison='who | grep -v tmux'
alias startvnc="vncserver -xstartup startxfce4; echo Use \"ssh -L 5901:localhost:5901 $(whoami)@$(hostname)\" to tunnel connections."
@ -35,7 +34,9 @@ alias vi=vim
alias view="vim -R"
alias top="top -o %CPU"
alias make-entrypoints="egrep '^[a-zA-Z0-9\-]*:' Makefile"
if [ -x `which torsocks 2>/dev/null` ] && [ `systemctl status tor 2>/dev/null| grep -c running` -eq 1 ]; then alias tor-lynx="torsocks lynx https://check.torproject.org/"; fi
if [ -x `which torsocks 2>/dev/null` ] && [ `systemctl status tor 2>/dev/null| grep -c running` -eq 1 ]; then
alias tor-lynx="torsocks lynx https://check.torproject.org/";
fi
IFS="
"
@ -71,4 +72,7 @@ if [ ! -z "$SSH_CLIENT" ]; then
fi
alias sdr="screen -d -r"
fi;
elif [ `who -m | egrep "^$(whoami)" | awk '{ print $2; }' | egrep -c "^tty"` -eq 1 ] && [ -x /usr/sbin/startxfce4 ]; then
exec startxfce4
fi

View File

@ -5,11 +5,6 @@
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Allow separation so that /usr/local/bin/replicate-ssh-profiles doesn't carry local-only customizations downstream.
if [ -f ~/.bashrc-local ]; then
. ~/.bashrc-local