Update RM55x_rcPCIe_toolkit.sh
This commit is contained in:
@@ -47,9 +47,9 @@ send_at_command() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$at_command" = "install" ]; then
|
if [ "$at_command" = "install" ]; then
|
||||||
install_update_at_socat
|
install_update_at_socat
|
||||||
echo -e "\e[1;32mInstalled. Type atcmd from adb shell or ssh to start an AT Command session\e[0m"
|
echo -e "\e[1;32mInstalled. Type atcmd from adb shell or ssh to start an AT Command session\e[0m"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
echo -e "${at_command}\r" > "$DEVICE_FILE"
|
echo -e "${at_command}\r" > "$DEVICE_FILE"
|
||||||
}
|
}
|
||||||
@@ -70,8 +70,8 @@ wait_for_response() {
|
|||||||
elapsed_time=$((current_time - start_time))
|
elapsed_time=$((current_time - start_time))
|
||||||
if [ "$elapsed_time" -ge "$TIMEOUT" ]; then
|
if [ "$elapsed_time" -ge "$TIMEOUT" ]; then
|
||||||
echo -e "\e[1;31mError: Response timed out.\e[0m" # Red
|
echo -e "\e[1;31mError: Response timed out.\e[0m" # Red
|
||||||
echo -e "\e[1;32mIf the response takes longer than a second or 2 to respond this will not work\e[0m" # Green
|
echo -e "\e[1;32mIf the response takes longer than a second or 2 to respond this will not work\e[0m" # Green
|
||||||
echo -e "\e[1;36mType install to install the better version of this that will work.\e[0m" # Cyan
|
echo -e "\e[1;36mType install to install the better version of this that will work.\e[0m" # Cyan
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
@@ -101,13 +101,6 @@ send_at_commands() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
overlay_check() {
|
|
||||||
if ! grep -qs '/real_rootfs ' /proc/mounts; then
|
|
||||||
echo -e "\e[31mYou have not ran Option 2 yet!!! Please run option 2!!\e[0m"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
basic_55x_setup() {
|
basic_55x_setup() {
|
||||||
# Check if neither /etc nor /real_rootfs is mounted
|
# Check if neither /etc nor /real_rootfs is mounted
|
||||||
if ! grep -qs '/etc ' /proc/mounts && ! grep -qs '/real_rootfs ' /proc/mounts; then
|
if ! grep -qs '/etc ' /proc/mounts && ! grep -qs '/real_rootfs ' /proc/mounts; then
|
||||||
@@ -116,20 +109,20 @@ basic_55x_setup() {
|
|||||||
echo -e "\033[31mI was expecting either /etc or /real_rootfs to be a mount point.\033[0m"
|
echo -e "\033[31mI was expecting either /etc or /real_rootfs to be a mount point.\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if /etc is mounted
|
# Check if /etc is mounted
|
||||||
if grep -qs '/etc ' /proc/mounts; then
|
if grep -qs '/etc ' /proc/mounts; then
|
||||||
echo "Unmounting /etc..."
|
echo "Unmounting /etc..."
|
||||||
umount -lf /etc
|
umount -lf /etc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if /real_rootfs is mounted
|
# Check if /real_rootfs is mounted
|
||||||
if grep -qs '/real_rootfs ' /proc/mounts; then
|
if grep -qs '/real_rootfs ' /proc/mounts; then
|
||||||
# Echo message in red
|
# Echo message in red
|
||||||
echo -e "\033[31mThe environment has already been setup. If you want to undo the changes temporarily run service mount-fix stop.\033[0m"
|
echo -e "\033[31mThe environment has already been setup. If you want to undo the changes temporarily run service mount-fix stop.\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /etc/init.d/
|
cd /etc/init.d/
|
||||||
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/development-SDXPINN/init.d/mount-fix
|
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/development-SDXPINN/init.d/mount-fix
|
||||||
# wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/development-SDXPINN/init.d/init-overlay-watchdog
|
# wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/development-SDXPINN/init.d/init-overlay-watchdog
|
||||||
@@ -147,65 +140,72 @@ basic_55x_setup() {
|
|||||||
echo -e "\e[0m"
|
echo -e "\e[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
ttl_setup() {
|
overlay_check() {
|
||||||
local ttl_file="/etc/firewall.user.ttl"
|
if ! grep -qs '/real_rootfs ' /proc/mounts; then
|
||||||
local lan_utils_script="/etc/data/lanUtils.sh"
|
echo -e "\e[31mYou have not ran Option 2 yet!!! Please run option 2!!\e[0m"
|
||||||
local combine_function="util_combine_iptable_rules"
|
return 1
|
||||||
local temp_file="/tmp/temp_firewall_user_ttl"
|
|
||||||
|
|
||||||
overlay_check || return
|
|
||||||
|
|
||||||
if [ -f "$ttl_file" ]; then
|
|
||||||
while true; do
|
|
||||||
echo "Would you like to edit the TTL settings? (yes to continue, exit to quit):"
|
|
||||||
read -r response
|
|
||||||
if [ "$response" = "exit" ]; then
|
|
||||||
echo "Exiting..."
|
|
||||||
break
|
|
||||||
elif [ "$response" = "yes" ]; then
|
|
||||||
if [ ! -s "$ttl_file" ]; then
|
|
||||||
echo -e "\e[31mTTL is not enabled\e[0m"
|
|
||||||
else
|
|
||||||
ipv4_ttl=$(grep 'iptables -t mangle -A POSTROUTING' "$ttl_file" | awk '{print $10}')
|
|
||||||
ipv6_ttl=$(grep 'ip6tables -t mangle -A POSTROUTING' "$ttl_file" | awk '{print $10}')
|
|
||||||
echo -e "\e[32mCurrent IPv4 TTL: $ipv4_ttl\e[0m"
|
|
||||||
echo -e "\e[32mCurrent IPv6 TTL: $ipv6_ttl\e[0m"
|
|
||||||
fi
|
|
||||||
echo -e "\e[32mType 0 to disable TTL\e[0m"
|
|
||||||
echo "Enter the TTL value (number only):"
|
|
||||||
read -r ttl_value
|
|
||||||
if ! [[ "$ttl_value" =~ ^[0-9]+$ ]]; then
|
|
||||||
echo "Invalid input, please enter a number."
|
|
||||||
else
|
|
||||||
if [ "$ttl_value" -eq 0 ]; then
|
|
||||||
echo "Disabling TTL..."
|
|
||||||
> "$ttl_file"
|
|
||||||
else
|
|
||||||
echo "Setting TTL to $ttl_value..."
|
|
||||||
echo "iptables -t mangle -A POSTROUTING -o rmnet+ -j TTL --ttl-set $ttl_value" > "$ttl_file"
|
|
||||||
echo "ip6tables -t mangle -A POSTROUTING -o rmnet+ -j HL --hl-set $ttl_value" >> "$ttl_file"
|
|
||||||
fi
|
|
||||||
/bin/bash "$lan_utils_script"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "Creating $ttl_file..."
|
|
||||||
touch "$ttl_file"
|
|
||||||
|
|
||||||
echo "Modifying $combine_function in $lan_utils_script..."
|
|
||||||
|
|
||||||
# Backup the original script
|
|
||||||
cp "$lan_utils_script" "${lan_utils_script}.bak"
|
|
||||||
|
|
||||||
# Check if the function already includes the ttl_firewall_file line
|
|
||||||
if ! grep -q "local ttl_firewall_file" "$lan_utils_script"; then
|
|
||||||
awk -v RS= -v ORS="\n\n" "/$combine_function/ {sub(/}/, \" local ttl_firewall_file=/etc/firewall.user.ttl\n\n #cleanup\n cat /dev/null > \$firewall_file\n\n #combine separate files to /etc/firewall.user\n if [ -f \\\"\$nat_firewall_file\\\" ]; then\n cat \$nat_firewall_file >> \$firewall_file\n fi\n if [ -f \\\"\$porttrigger_firewall_file\\\" ]; then\n cat \$porttrigger_firewall_file >> \$firewall_file\n fi\n if [ -f \\\"\$tcpmss_firewall_filev4\\\" ]; then\n cat \$tcpmss_firewall_filev4 >> \$firewall_file\n fi\n if [ -f \\\"\$tcpmss_firewall_filev6\\\" ]; then\n cat \$tcpmss_firewall_filev6 >> \$firewall_file\n fi\n if [ -f \\\"\$ttl_firewall_file\\\" ]; then\n cat \$ttl_firewall_file >> \$firewall_file\n fi\n}\");} 1" "$lan_utils_script" > "$temp_file" && mv "$temp_file" "$lan_utils_script"
|
|
||||||
fi
|
|
||||||
ttl_setup
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ttl_setup() {
|
||||||
|
local ttl_file="/etc/firewall.user.ttl"
|
||||||
|
local lan_utils_script="/etc/data/lanUtils.sh"
|
||||||
|
local combine_function="util_combine_iptable_rules"
|
||||||
|
local temp_file="/tmp/temp_firewall_user_ttl"
|
||||||
|
|
||||||
|
overlay_check || return
|
||||||
|
|
||||||
|
if [ -f "$ttl_file" ]; then
|
||||||
|
while true; do
|
||||||
|
echo "Would you like to edit the TTL settings? (yes to continue, exit to quit):"
|
||||||
|
read -r response
|
||||||
|
if [ "$response" = "exit" ]; then
|
||||||
|
echo "Exiting..."
|
||||||
|
break
|
||||||
|
elif [ "$response" = "yes" ]; then
|
||||||
|
if [ ! -s "$ttl_file" ]; then
|
||||||
|
echo -e "\e[31mTTL is not enabled\e[0m"
|
||||||
|
else
|
||||||
|
ipv4_ttl=$(grep 'iptables -t mangle -A POSTROUTING' "$ttl_file" | awk '{print $10}')
|
||||||
|
ipv6_ttl=$(grep 'ip6tables -t mangle -A POSTROUTING' "$ttl_file" | awk '{print $10}')
|
||||||
|
echo -e "\e[32mCurrent IPv4 TTL: $ipv4_ttl\e[0m"
|
||||||
|
echo -e "\e[32mCurrent IPv6 TTL: $ipv6_ttl\e[0m"
|
||||||
|
fi
|
||||||
|
echo -e "\e[32mType 0 to disable TTL\e[0m"
|
||||||
|
echo "Enter the TTL value (number only):"
|
||||||
|
read -r ttl_value
|
||||||
|
if ! [[ "$ttl_value" =~ ^[0-9]+$ ]]; then
|
||||||
|
echo "Invalid input, please enter a number."
|
||||||
|
else
|
||||||
|
if [ "$ttl_value" -eq 0 ]; then
|
||||||
|
echo "Disabling TTL..."
|
||||||
|
> "$ttl_file"
|
||||||
|
else
|
||||||
|
echo "Setting TTL to $ttl_value..."
|
||||||
|
echo "iptables -t mangle -A POSTROUTING -o rmnet+ -j TTL --ttl-set $ttl_value" > "$ttl_file"
|
||||||
|
echo "ip6tables -t mangle -A POSTROUTING -o rmnet+ -j HL --hl-set $ttl_value" >> "$ttl_file"
|
||||||
|
fi
|
||||||
|
/bin/bash "$lan_utils_script"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "Creating $ttl_file..."
|
||||||
|
touch "$ttl_file"
|
||||||
|
|
||||||
|
echo "Modifying $combine_function in $lan_utils_script..."
|
||||||
|
|
||||||
|
# Backup the original script
|
||||||
|
cp "$lan_utils_script" "${lan_utils_script}.bak"
|
||||||
|
|
||||||
|
# Check if the function already includes the ttl_firewall_file line
|
||||||
|
if ! grep -q "local ttl_firewall_file" "$lan_utils_script"; then
|
||||||
|
awk -v RS= -v ORS="\n\n" "/$combine_function/ {sub(/}/, \" local ttl_firewall_file=/etc/firewall.user.ttl\n\n #cleanup\n cat /dev/null > \$firewall_file\n\n #combine separate files to /etc/firewall.user\n if [ -f \\\"\$nat_firewall_file\\\" ]; then\n cat \$nat_firewall_file >> \$firewall_file\n fi\n if [ -f \\\"\$porttrigger_firewall_file\\\" ]; then\n cat \$porttrigger_firewall_file >> \$firewall_file\n fi\n if [ -f \\\"\$tcpmss_firewall_filev4\\\" ]; then\n cat \$tcpmss_firewall_filev4 >> \$firewall_file\n fi\n if [ -f \\\"\$tcpmss_firewall_filev6\\\" ]; then\n cat \$tcpmss_firewall_filev6 >> \$firewall_file\n fi\n if [ -f \\\"\$ttl_firewall_file\\\" ]; then\n cat \$ttl_firewall_file >> \$firewall_file\n fi\n}\");} 1" "$lan_utils_script" > "$temp_file" && mv "$temp_file" "$lan_utils_script"
|
||||||
|
fi
|
||||||
|
ttl_setup
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function for Tailscale Submenu
|
# Function for Tailscale Submenu
|
||||||
tailscale_menu() {
|
tailscale_menu() {
|
||||||
while true; do
|
while true; do
|
||||||
@@ -216,10 +216,10 @@ tailscale_menu() {
|
|||||||
read -p "Enter your choice: " tailscale_choice
|
read -p "Enter your choice: " tailscale_choice
|
||||||
|
|
||||||
case $tailscale_choice in
|
case $tailscale_choice in
|
||||||
1) install_update_tailscale ;;
|
1) install_update_tailscale;;
|
||||||
2) configure_tailscale ;;
|
2) configure_tailscale;;
|
||||||
3) break ;;
|
3) break;;
|
||||||
*) echo "Invalid option" ;;
|
*) echo "Invalid option";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -327,13 +327,13 @@ while true; do
|
|||||||
echo "Welcome to iamromulan's rcPCIe Toolkit script for Quectel RM55x Series modems!"
|
echo "Welcome to iamromulan's rcPCIe Toolkit script for Quectel RM55x Series modems!"
|
||||||
echo "Visit https://github.com/iamromulan for more!"
|
echo "Visit https://github.com/iamromulan for more!"
|
||||||
echo -e "\e[0m"
|
echo -e "\e[0m"
|
||||||
echo -e "\e[91mThis is a test version of the toolkit for the new RM550/551 modems\e[0m" # Light Red
|
echo -e "\e[91mThis is a test version of the toolkit for the new RM550/551 modems\e[0m" # Light Red
|
||||||
echo "Select an option:"
|
echo "Select an option:"
|
||||||
echo -e "\e[0m"
|
echo -e "\e[0m"
|
||||||
echo -e "\e[96m1) Send AT Commands\e[0m" # Cyan
|
echo -e "\e[96m1) Send AT Commands\e[0m" # Cyan
|
||||||
echo -e "\e[92m2) First time setup/run me after a flash!\e[0m" # Green
|
echo -e "\e[92m2) First time setup/run me after a flash!\e[0m" # Green
|
||||||
echo -e "\e[94m3) TTL Setup\e[0m" # Light Blue
|
echo -e "\e[94m3) TTL Setup\e[0m" # Light Blue
|
||||||
echo -e "\e[94m4) Set root password\e[0m" # Light Blue
|
echo -e "\e[94m4) Set root password\e[0m" # Light Blue
|
||||||
echo -e "\e[94m5) Tailscale Management\e[0m" # Light Blue
|
echo -e "\e[94m5) Tailscale Management\e[0m" # Light Blue
|
||||||
echo -e "\e[92m6) Install Speedtest.net CLI app (speedtest command)\e[0m" # Light Green
|
echo -e "\e[92m6) Install Speedtest.net CLI app (speedtest command)\e[0m" # Light Green
|
||||||
echo -e "\e[93m7) Exit\e[0m" # Yellow (repeated color for exit option)
|
echo -e "\e[93m7) Exit\e[0m" # Yellow (repeated color for exit option)
|
||||||
@@ -342,20 +342,10 @@ while true; do
|
|||||||
case $choice in
|
case $choice in
|
||||||
1) send_at_commands ;;
|
1) send_at_commands ;;
|
||||||
2) remount_rw; basic_55x_setup ;;
|
2) remount_rw; basic_55x_setup ;;
|
||||||
3)
|
3) ttl_setup ;;
|
||||||
overlay_check
|
4) set_root_passwd ;;
|
||||||
if [ $? -eq 1 ]; then continue; fi
|
|
||||||
ttl_setup
|
|
||||||
;;
|
|
||||||
4)
|
|
||||||
overlay_check
|
|
||||||
if [ $? -eq 1 ]; then continue; fi
|
|
||||||
set_root_passwd
|
|
||||||
;;
|
|
||||||
5) tailscale_menu ;;
|
5) tailscale_menu ;;
|
||||||
6)
|
6)
|
||||||
overlay_check
|
|
||||||
if [ $? -eq 1 ]; then continue; fi
|
|
||||||
echo -e "\e[1;32mInstalling Speedtest.net CLI (speedtest command)\e[0m"
|
echo -e "\e[1;32mInstalling Speedtest.net CLI (speedtest command)\e[0m"
|
||||||
# Add Logic to confirm we are overlayed over the larger /data
|
# Add Logic to confirm we are overlayed over the larger /data
|
||||||
cd /usr/bin
|
cd /usr/bin
|
||||||
|
|||||||
Reference in New Issue
Block a user