Made a few changes to lighttpd

This commit is contained in:
Zach Brown
2024-04-09 02:03:26 +00:00
parent 05c387d539
commit c82d9496a7
2 changed files with 66 additions and 73 deletions

View File

@@ -1,12 +1,15 @@
#!/bin/sh
# Define toolkit paths
GITUSER="iamromulan"
GITTREE="development"
GITUSER="snowzach"
GITTREE="lighttpd"
# GITUSER="iamromulan"
# GITTREE="development"
TMP_DIR="/tmp"
USRDATA_DIR="/usrdata"
SOCAT_AT_DIR="/usrdata/socat-at-bridge"
SOCAT_AT_SYSD_DIR="/usrdata/socat-at-bridge/systemd_units"
LIGHTTPD_DIR="/usrdata/lighttpd"
SIMPLE_ADMIN_DIR="/usrdata/simpleadmin"
SIMPLE_FIREWALL_DIR="/usrdata/simplefirewall"
SIMPLE_FIREWALL_SCRIPT="$SIMPLE_FIREWALL_DIR/simplefirewall.sh"
@@ -97,6 +100,21 @@ send_at_commands() {
fi
}
# Check for existing Entware/opkg installation, install if not installed
ensure_entware_installed() {
if [ ! -f "/opt/bin/opkg" ]; then
echo -e "\e[1;32mInstalling Entware/OPKG\e[0m"
cd /tmp && wget -O installentware.sh "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/installentware.sh" && chmod +x installentware.sh && ./installentware.sh
if [ "$?" -ne 0 ]; then
echo -e "\e[1;31mEntware/OPKG installation failed. Please check your internet connection or the repository URL.\e[0m"
exit 1
fi
cd /
else
echo -e "\e[1;32mEntware/OPKG is already installed.\e[0m"
fi
}
# Check if Simple Admin is installed
is_simple_admin_installed() {
[ -d "$SIMPLE_ADMIN_DIR" ] && return 0 || return 1
@@ -300,20 +318,38 @@ configure_simple_firewall() {
echo -e "\e[1;32mFirewall configuration updated.\e[0m"
}
# Function to install Lighttpd
install_lighttpd() {
ensure_entware_installed
/opt/bin/opkg install lighttpd lighttpd-mod-auth lighttpd-mod-authn_file lighttpd-mod-cgi lighttpd-mod-openssl lighttpd-mod-proxy
systemctl stop lighttpd
echo -e "\033[0;32mInstalling/Updating Lighttpd...\033[0m"
mount -o remount,rw /
mkdir -p "$LIGHTTPD_DIR"
wget -O "$LIGHTTPD_DIR/lighttpd.conf" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/lighttpd/lighttpd.conf
wget -O "$LIGHTTPD_DIR/lighttpd.service" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/lighttpd/lighttpd.service
ln -sf "$LIGHTTPD_DIR/lighttpd.service" "/lib/systemd/system/lighttpd.service"
openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 \
-subj "/C=US/ST=MI/L=Romulus/O=RMIITools/CN=localhost" \
-keyout $LIGHTTPD_DIR/server.key -out $LIGHTTPD_DIR/server.crt
systemctl daemon-reload
systemctl enable lighttpd
systemctl start lighttpd
remount_ro
echo -e "\033[0;32mSimple Firewall installation/update complete.\033[0m"
echo -e "\e[1;31mPlease set your system login password.\e[0m"
#printf "USER:$(openssl passwd -crypt PASSWORD)\n" >> .htpasswd
}
# Function to install/update Simple Admin
install_simple_admin() {
# Check for existing Entware/opkg installation, install if not installed
if [ ! -f "/opt/bin/opkg" ]; then
echo -e "\e[1;32mInstalling Entware/OPKG\e[0m"
cd /tmp && wget -O installentware.sh "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/installentware.sh" && chmod +x installentware.sh && ./installentware.sh
if [ "$?" -ne 0 ]; then
echo -e "\e[1;31mEntware/OPKG installation failed. Please check your internet connection or the repository URL.\e[0m"
exit 1
fi
cd /
else
echo -e "\e[1;32mEntware/OPKG is already installed.\e[0m"
fi
install_lighttpd
while true; do
echo -e "\e[1;32mWhat version of Simple Admin do you want to install? This will start a webserver on port 8080\e[0m"
echo -e "\e[1;32m1) Stable current version, (Main Branch)\e[0m"
@@ -836,18 +872,8 @@ WantedBy=multi-user.target" > "$cfun_service_path"
install_ttyd() {
echo -e "\e[1;34mStarting ttyd installation process...\e[0m"
# Check for existing Entware/opkg installation, install if not installed
if [ ! -f "/opt/bin/opkg" ]; then
echo -e "\e[1;32mInstalling Entware/OPKG\e[0m"
cd /tmp && wget -O installentware.sh "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/installentware.sh" && chmod +x installentware.sh && ./installentware.sh
if [ "$?" -ne 0 ]; then
echo -e "\e[1;31mEntware/OPKG installation failed. Please check your internet connection or the repository URL.\e[0m"
exit 1
fi
cd /
else
echo -e "\e[1;32mEntware/OPKG is already installed.\e[0m"
fi
ensure_entware_installed
mount -o remount,rw /
@@ -1020,34 +1046,21 @@ echo " :+##+. "
4)
tailscale_menu
;;
;;
5)
manage_reboot_timer
manage_reboot_timer
;;
6)
manage_cfun_fix
manage_cfun_fix
;;
7)
echo -e "\e[1;32mInstalling Entware/OPKG\e[0m"
cd /tmp && wget -O installentware.sh https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/installentware.sh && chmod +x installentware.sh && ./installentware.sh && cd /
7)
ensure_entware_installed
;;
8)
install_ttyd
;;
;;
9)
echo -e "\e[1;32mInstalling Speedtest.net CLI (speedtest command)\e[0m"
# Check for existing Entware/opkg installation, install if not installed
if [ ! -f "/opt/bin/opkg" ]; then
echo -e "\e[1;32mInstalling Entware/OPKG\e[0m"
cd /tmp && wget -O installentware.sh "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/installentware.sh" && chmod +x installentware.sh && ./installentware.sh
if [ "$?" -ne 0 ]; then
echo -e "\e[1;31mEntware/OPKG installation failed. Please check your internet connection or the repository URL.\e[0m"
exit 1
fi
cd /
else
echo -e "\e[1;32mEntware/OPKG is already installed.\e[0m"
fi
ensure_entware_installed
echo -e "\e[1;32mInstalling Speedtest.net CLI (speedtest command)\e[0m"
remount_rw
mkdir /usrdata/root
@@ -1084,8 +1097,8 @@ echo " :+##+. "
echo -e "\e[1;32mGoodbye!\e[0m"
break
;;
*)
echo -e "\e[1;31mInvalid option\e[0m"
*)
echo -e "\e[1;31mInvalid option\e[0m"
;;
esac
done

View File

@@ -92,29 +92,12 @@ Type=none
Options=bind
[Install]
WantedBy=multi-user.target
WantedBy=local-fs.target
EOF
systemctl daemon-reload
systemctl enable opt.mount
systemctl start opt.mount
# Additional systemd service to ensure opt.mount starts at boot
echo -e '\033[32mInfo: Creating service to start opt.mount at boot...\033[0m'
cat <<EOF > /lib/systemd/system/start-opt-mount.service
[Unit]
Description=Ensure opt.mount is started at boot
After=network.target
[Service]
Type=oneshot
ExecStart=/bin/systemctl start opt.mount
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
ln -s /lib/systemd/system/start-opt-mount.service /lib/systemd/system/multi-user.target.wants/start-opt-mount.service
}
if [ -n "$PRE_OPKG_PATH" ]; then
@@ -222,8 +205,8 @@ opkg update && opkg install shadow-login shadow-passwd
# Replace the login and passwd binaries and set home for root to a writable directory
rm /opt/etc/shadow
rm /opt/etc/passwd
cp /etc/shadow /opt/etc/
cp /etc/passwd /opt/etc
ln -s /etc/shadow /opt/etc/
ln -s /etc/passwd /opt/etc
mkdir /usrdata/root
mkdir /usrdata/root/bin
touch /usrdata/root/.profile
@@ -239,12 +222,9 @@ opkg update && opkg install shadow-login shadow-passwd
# Install basic and useful utilites
opkg install mc
ln -sf /opt/bin/mc /bin
opkg install htop
ln -sf /opt/bin/htop /bin
opkg install dfc
ln -sf /opt/bin/dfc /bin
opkg install lsof
ln -sf /opt/bin/lsof /bin
# Remount filesystem as read-only
mount -o remount,ro /