Make script more efficient
We don't need to be downloading the entire main.zip lol
This commit is contained in:
@@ -4,9 +4,12 @@
|
|||||||
USRDATA_DIR="/usrdata"
|
USRDATA_DIR="/usrdata"
|
||||||
MICROPYTHON_DIR="/usrdata/micropython"
|
MICROPYTHON_DIR="/usrdata/micropython"
|
||||||
AT_TELNET_DIR="/usrdata/at-telnet"
|
AT_TELNET_DIR="/usrdata/at-telnet"
|
||||||
|
AT_TELNET_SYSD_DIR="/usrdata/at-telnet/systemd_units"
|
||||||
|
AT_TELNET_SMD7_SYSD_DIR="/usrdata/at-telnet/smd7_systemd_units"
|
||||||
SIMPLE_ADMIN_DIR="/usrdata/simpleadmin"
|
SIMPLE_ADMIN_DIR="/usrdata/simpleadmin"
|
||||||
TMP_DIR="/tmp"
|
TMP_DIR="/tmp"
|
||||||
GITHUB_URL="https://github.com/iamromulan/quectel-rgmii-toolkit/archive/refs/heads/main.zip"
|
GITHUB_URL="https://github.com/iamromulan/quectel-rgmii-toolkit/archive/refs/heads/main.zip"
|
||||||
|
GITHUB_SIMPADMIN_FULL_URL="https://github.com/iamromulan/quectel-rgmii-toolkit/archive/refs/heads/simpleadminfull.zip"
|
||||||
GITHUB_SIMPADMIN_NOCMD_URL="https://github.com/iamromulan/quectel-rgmii-toolkit/archive/refs/heads/simpleadminnoatcmds.zip"
|
GITHUB_SIMPADMIN_NOCMD_URL="https://github.com/iamromulan/quectel-rgmii-toolkit/archive/refs/heads/simpleadminnoatcmds.zip"
|
||||||
GITHUB_SIMPADMIN_TTL_URL="https://github.com/iamromulan/quectel-rgmii-toolkit/archive/refs/heads/simpleadminttlonly.zip"
|
GITHUB_SIMPADMIN_TTL_URL="https://github.com/iamromulan/quectel-rgmii-toolkit/archive/refs/heads/simpleadminttlonly.zip"
|
||||||
TAILSCALE_DIR="/usrdata/tailscale/"
|
TAILSCALE_DIR="/usrdata/tailscale/"
|
||||||
@@ -99,11 +102,35 @@ remount_ro() {
|
|||||||
# Function to install/update AT Telnet Daemon
|
# Function to install/update AT Telnet Daemon
|
||||||
install_update_at_telnet() {
|
install_update_at_telnet() {
|
||||||
remount_rw
|
remount_rw
|
||||||
cd $TMP_DIR
|
mkdir $MICROPYTHON_DIR
|
||||||
wget $GITHUB_URL -O main.zip
|
mkdir $AT_TELNET_DIR
|
||||||
unzip -o main.zip
|
cd $MICROPYTHON_DIR
|
||||||
cp -Rf quectel-rgmii-toolkit-main/attelnetdaemon/at-telnet $USRDATA_DIR
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/micropython/errno.py
|
||||||
cp -Rf quectel-rgmii-toolkit-main/attelnetdaemon/micropython $USRDATA_DIR
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/micropython/fcntl.py
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/micropython/ffilib.py
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/micropython/logging.py
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/micropython/micropython
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/micropython/os_compat.py
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/micropython/serial.py
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/micropython/stat.py
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/micropython/time.py
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/micropython/traceback.mpy
|
||||||
|
cd $AT_TELNET_DIR
|
||||||
|
mkdir $AT_TELNET_SYSD_DIR
|
||||||
|
mkdir $AT_TELNET_SMD7_SYSD_DIR
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/at-telnet/modem-multiclient.py
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/at-telnet/picocom
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/at-telnet/socat-armel-static
|
||||||
|
cd $AT_TELNET_SYSD_DIR
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/at-telnet/systemd_units/socat-smd11.service
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/at-telnet/systemd_units/at-telnet-daemon.service
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/at-telnet/systemd_units/socat-smd11-from-ttyIN.service
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/at-telnet/systemd_units/socat-smd11-to-ttyIN.service
|
||||||
|
cd $AT_TELNET_SMD7_SYSD_DIR
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/at-telnet/smd7_systemd_units/at-telnet-daemon.service
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/at-telnet/smd7_systemd_units/socat-smd7-from-ttyIN.service
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/at-telnet/smd7_systemd_units/socat-smd7-to-ttyIN.service
|
||||||
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/attelnetdaemon/at-telnet/smd7_systemd_units/socat-smd7.service
|
||||||
|
|
||||||
# Set execute permissions
|
# Set execute permissions
|
||||||
chmod +x $MICROPYTHON_DIR/micropython
|
chmod +x $MICROPYTHON_DIR/micropython
|
||||||
@@ -119,6 +146,7 @@ install_update_at_telnet() {
|
|||||||
read -p "Enter your choice (1 or 2): " device_choice
|
read -p "Enter your choice (1 or 2): " device_choice
|
||||||
|
|
||||||
# Stop and disable existing services before installing new ones
|
# Stop and disable existing services before installing new ones
|
||||||
|
set +x
|
||||||
systemctl stop at-telnet-daemon
|
systemctl stop at-telnet-daemon
|
||||||
systemctl disable at-telnet-daemon
|
systemctl disable at-telnet-daemon
|
||||||
systemctl stop socat-smd11
|
systemctl stop socat-smd11
|
||||||
@@ -135,11 +163,12 @@ install_update_at_telnet() {
|
|||||||
rm /lib/systemd/system/socat-smd7-to-ttyIN.service
|
rm /lib/systemd/system/socat-smd7-to-ttyIN.service
|
||||||
rm /lib/systemd/system/socat-smd7-from-ttyIN.service
|
rm /lib/systemd/system/socat-smd7-from-ttyIN.service
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
set -x
|
||||||
|
|
||||||
# Depending on the choice, copy the respective systemd unit files
|
# Depending on the choice, copy the respective systemd unit files
|
||||||
case $device_choice in
|
case $device_choice in
|
||||||
2)
|
2)
|
||||||
cp -f $AT_TELNET_DIR/smd7_systemd_units/*.service /lib/systemd/system
|
cp -f $AT_TELNET_SMD7_SYSD_DIR/*.service /lib/systemd/system
|
||||||
ln -sf /lib/systemd/system/socat-smd7.service /lib/systemd/system/multi-user.target.wants/
|
ln -sf /lib/systemd/system/socat-smd7.service /lib/systemd/system/multi-user.target.wants/
|
||||||
ln -sf /lib/systemd/system/socat-smd7-to-ttyIN.service /lib/systemd/system/multi-user.target.wants/
|
ln -sf /lib/systemd/system/socat-smd7-to-ttyIN.service /lib/systemd/system/multi-user.target.wants/
|
||||||
ln -sf /lib/systemd/system/socat-smd7-from-ttyIN.service /lib/systemd/system/multi-user.target.wants/
|
ln -sf /lib/systemd/system/socat-smd7-from-ttyIN.service /lib/systemd/system/multi-user.target.wants/
|
||||||
@@ -150,7 +179,7 @@ install_update_at_telnet() {
|
|||||||
systemctl start socat-smd7-from-ttyIN
|
systemctl start socat-smd7-from-ttyIN
|
||||||
;;
|
;;
|
||||||
1)
|
1)
|
||||||
cp -f $AT_TELNET_DIR/systemd_units/*.service /lib/systemd/system
|
cp -f $AT_TELNET_SYSD_DIR/*.service /lib/systemd/system
|
||||||
ln -sf /lib/systemd/system/socat-smd11.service /lib/systemd/system/multi-user.target.wants/
|
ln -sf /lib/systemd/system/socat-smd11.service /lib/systemd/system/multi-user.target.wants/
|
||||||
ln -sf /lib/systemd/system/socat-smd11-to-ttyIN.service /lib/systemd/system/multi-user.target.wants/
|
ln -sf /lib/systemd/system/socat-smd11-to-ttyIN.service /lib/systemd/system/multi-user.target.wants/
|
||||||
ln -sf /lib/systemd/system/socat-smd11-from-ttyIN.service /lib/systemd/system/multi-user.target.wants/
|
ln -sf /lib/systemd/system/socat-smd11-from-ttyIN.service /lib/systemd/system/multi-user.target.wants/
|
||||||
@@ -181,16 +210,8 @@ install_update_at_telnet() {
|
|||||||
# Start Services
|
# Start Services
|
||||||
systemctl start at-telnet-daemon
|
systemctl start at-telnet-daemon
|
||||||
remount_ro
|
remount_ro
|
||||||
# Cleanup
|
|
||||||
echo "Cleaning up..."
|
|
||||||
rm /tmp/main.zip
|
|
||||||
rm -rf /tmp/quectel-rgmii-toolkit-main/
|
|
||||||
else
|
else
|
||||||
remount_ro
|
remount_ro
|
||||||
# Cleanup
|
|
||||||
echo "Cleaning up..."
|
|
||||||
rm /tmp/main.zip
|
|
||||||
rm -rf /tmp/quectel-rgmii-toolkit-main/
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -241,10 +262,6 @@ remove_at_telnet() {
|
|||||||
|
|
||||||
# Remove the AT Telnet Daemon directory
|
# Remove the AT Telnet Daemon directory
|
||||||
rm -rf $AT_TELNET_DIR
|
rm -rf $AT_TELNET_DIR
|
||||||
|
|
||||||
# Additional cleanup if necessary
|
|
||||||
# (Add any other file or directory removals here if needed)
|
|
||||||
|
|
||||||
remount_ro
|
remount_ro
|
||||||
echo "AT Telnet Daemon removed successfully."
|
echo "AT Telnet Daemon removed successfully."
|
||||||
}
|
}
|
||||||
@@ -266,9 +283,9 @@ install_update_simple_admin() {
|
|||||||
1)
|
1)
|
||||||
remount_rw
|
remount_rw
|
||||||
cd $TMP_DIR
|
cd $TMP_DIR
|
||||||
wget $GITHUB_URL -O main.zip
|
wget $GITHUB_SIMPADMIN_FULL_URL -O simpleadminfull.zip
|
||||||
unzip -o main.zip
|
unzip -o simpleadminfull.zip
|
||||||
cp -Rf quectel-rgmii-toolkit-main/simpleadmin/ $USRDATA_DIR
|
cp -Rf quectel-rgmii-toolkit-simpleadminfull/simpleadmin/ $USRDATA_DIR
|
||||||
|
|
||||||
chmod +x $SIMPLE_ADMIN_DIR/scripts/*
|
chmod +x $SIMPLE_ADMIN_DIR/scripts/*
|
||||||
chmod +x $SIMPLE_ADMIN_DIR/www/cgi-bin/*
|
chmod +x $SIMPLE_ADMIN_DIR/www/cgi-bin/*
|
||||||
|
|||||||
Reference in New Issue
Block a user