mirror of
https://github.com/QSCTech/zjunet.git
synced 2026-01-22 19:54:48 +08:00
wlan.sh: remove some possible bashisms in lib/wlan.sh
The shebang line specifies that executing the script using Bourne shell while some of the code uses possible bashisms like "[[" instead of "[" and "==" instead of "=". If a user's /bin/sh is linked to other shells like "dash, ksh, etc...", it might cause an issue for using the program.
This commit is contained in:
parent
d5bf090f4b
commit
6747ef8c4a
14
lib/wlan.sh
14
lib/wlan.sh
@ -31,7 +31,7 @@ USER="${BASEDIR}/user.sh"
|
|||||||
USERNAME=$($USER get)
|
USERNAME=$($USER get)
|
||||||
PASSWORD=$($USER getpwd $USERNAME)
|
PASSWORD=$($USER getpwd $USERNAME)
|
||||||
|
|
||||||
if [[ -f "${DISABLE_CHECK}" ]]; then
|
if [ -f "${DISABLE_CHECK}" ]; then
|
||||||
echo WLAN function has been disabled.;
|
echo WLAN function has been disabled.;
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
@ -43,10 +43,10 @@ logout() {
|
|||||||
echo "Logout: ${USERNAME}"
|
echo "Logout: ${USERNAME}"
|
||||||
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=logout&username=${USERNAME}&password=${PASSWORD}&ajax=1" -s)
|
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=logout&username=${USERNAME}&password=${PASSWORD}&ajax=1" -s)
|
||||||
|
|
||||||
if [[ $? -eq 60 ]]; then
|
if [ $? -eq 60 ]; then
|
||||||
CHOOSE=''
|
CHOOSE=''
|
||||||
read -p "There's an issue with ZJUNET's CA certificates, do you want to do it anyway? [yes/NO] " CHOOSE
|
read -p "There's an issue with ZJUNET's CA certificates, do you want to do it anyway? [yes/NO] " CHOOSE
|
||||||
if [[ $CHOOSE == "YES" ]] || [[ $CHOOSE == "yes" ]]; then
|
if [ $CHOOSE = "YES" ] || [ $CHOOSE = "yes" ]; then
|
||||||
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=logout&username=${USERNAME}&password=${PASSWORD}&ajax=1" -s -k)
|
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=logout&username=${USERNAME}&password=${PASSWORD}&ajax=1" -s -k)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -71,7 +71,7 @@ login() {
|
|||||||
PASSWORD=$2
|
PASSWORD=$2
|
||||||
|
|
||||||
STATUS=$(curl http://g.cn/generate_204 -I -s | grep HTTP | awk {'print $2'})
|
STATUS=$(curl http://g.cn/generate_204 -I -s | grep HTTP | awk {'print $2'})
|
||||||
if [[ STATUS -eq 204 ]]; then
|
if [ STATUS -eq 204 ]; then
|
||||||
echo "You have already logged in."
|
echo "You have already logged in."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -79,10 +79,10 @@ login() {
|
|||||||
echo "Login: ${USERNAME}"
|
echo "Login: ${USERNAME}"
|
||||||
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=login&username=${USERNAME}&password=${PASSWORD}&ac_id=3&user_ip=&nas_ip=&user_mac=&save_me=1&ajax=1" -s)
|
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=login&username=${USERNAME}&password=${PASSWORD}&ac_id=3&user_ip=&nas_ip=&user_mac=&save_me=1&ajax=1" -s)
|
||||||
|
|
||||||
if [[ $? -eq 60 ]]; then
|
if [ $? -eq 60 ]; then
|
||||||
CHOOSE=''
|
CHOOSE=''
|
||||||
read -p "There's an issue with ZJUNET's CA certificates, do you want to do it anyway? [yes/NO] " CHOOSE
|
read -p "There's an issue with ZJUNET's CA certificates, do you want to do it anyway? [yes/NO] " CHOOSE
|
||||||
if [[ $CHOOSE == "YES" ]] || [[ $CHOOSE == "yes" ]]; then
|
if [ $CHOOSE = "YES" ] || [ $CHOOSE = "yes" ]; then
|
||||||
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=login&username=${USERNAME}&password=${PASSWORD}&ac_id=3&user_ip=&nas_ip=&user_mac=&save_me=1&ajax=1" -s -k)
|
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=login&username=${USERNAME}&password=${PASSWORD}&ac_id=3&user_ip=&nas_ip=&user_mac=&save_me=1&ajax=1" -s -k)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -101,7 +101,7 @@ login() {
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Login: failed." >&2
|
echo "Login: failed." >&2
|
||||||
if [[ -z "${RESPONSE}" ]]; then
|
if [ -z "${RESPONSE}" ]; then
|
||||||
echo "Login: (Empty response)" >&2
|
echo "Login: (Empty response)" >&2
|
||||||
else
|
else
|
||||||
echo "Login: ${RESPONSE}" >&2
|
echo "Login: ${RESPONSE}" >&2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user