SDXPINN branch is now ipk focused
-Updated opkg-feed with new packages -Updated key cause I lost my private key
This commit is contained in:
116
ipk-source/sdxpinn-console-menu/root/usr/bin/download
Executable file
116
ipk-source/sdxpinn-console-menu/root/usr/bin/download
Executable file
@@ -0,0 +1,116 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Disabled for now
|
||||
# Determine the absolute path of the script
|
||||
SCRIPT_PATH=$(realpath "$0")
|
||||
|
||||
#download() {
|
||||
# if [ "$1" = "github" ]; then
|
||||
# download_github_directory "$2" "$3"
|
||||
# else
|
||||
# download_file "$1" "$2"
|
||||
# fi
|
||||
#}
|
||||
|
||||
download_file() {
|
||||
url="$1"
|
||||
output="${2:-$(basename "$url")}"
|
||||
|
||||
echo "Attempting to download file from URL: $url"
|
||||
echo "Saving to output: $output"
|
||||
|
||||
# Ensure the output directory exists
|
||||
mkdir -p "$(dirname "$output")"
|
||||
|
||||
if command -v curl > /dev/null 2>&1; then
|
||||
curl -L -o "$output" "$url"
|
||||
elif command -v wget > /dev/null 2>&1; then
|
||||
wget -O "$output" "$url"
|
||||
else
|
||||
echo "Error: Neither curl nor wget is available."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
download_github_directory() {
|
||||
github_url="$1"
|
||||
output_dir="${2:-.}" # Set output directory to the provided parameter or current directory
|
||||
|
||||
repo_info=$(echo "$github_url" | sed -n 's|https://github.com/\([^/]*\)/\([^/]*\)/tree/\([^/]*\)/\(.*\)|\1 \2 \3 \4|p')
|
||||
owner=$(echo "$repo_info" | cut -d' ' -f1)
|
||||
repo=$(echo "$repo_info" | cut -d' ' -f2)
|
||||
branch=$(echo "$repo_info" | cut -d' ' -f3)
|
||||
directory=$(echo "$repo_info" | cut -d' ' -f4)
|
||||
|
||||
echo "Owner: $owner, Repo: $repo, Branch: $branch, Directory: $directory"
|
||||
|
||||
if [ -z "$owner" ] || [ -z "$repo" ] || [ -z "$branch" ] || [ -z "$directory" ]; then
|
||||
echo "Error: Invalid GitHub URL."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Output directory set to: $output_dir"
|
||||
|
||||
api_url="https://api.github.com/repos/$owner/$repo/contents/$directory?ref=$branch"
|
||||
echo "Fetching directory contents from API URL: $api_url"
|
||||
|
||||
if command -v curl > /dev/null 2>&1; then
|
||||
contents=$(curl -s -H "Accept: application/vnd.github.v3+json" "$api_url")
|
||||
elif command -v wget > /dev/null 2>&1; then
|
||||
contents=$(wget -qO- --header="Accept: application/vnd.github.v3+json" "$api_url")
|
||||
else
|
||||
echo "Error: Neither curl nor wget is available."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "API Response Contents:"
|
||||
echo "$contents"
|
||||
|
||||
# Use awk to parse JSON content and prepare commands
|
||||
echo "$contents" | awk -v output_dir="$output_dir" -v owner="$owner" -v repo="$repo" -v branch="$branch" -v script_path="$SCRIPT_PATH" '
|
||||
BEGIN {
|
||||
RS="},"; FS=","; # Set Record Separator to "}," and Field Separator to ","
|
||||
}
|
||||
/"type": "file"/ {
|
||||
file_path = ""; download_url = "";
|
||||
for (i = 1; i <= NF; i++) {
|
||||
if ($i ~ /"path": "/) {
|
||||
gsub(/.*"path": "/, "", $i);
|
||||
gsub(/".*/, "", $i);
|
||||
file_path = $i;
|
||||
}
|
||||
if ($i ~ /"download_url": "/) {
|
||||
gsub(/.*"download_url": "/, "", $i);
|
||||
gsub(/".*/, "", $i);
|
||||
download_url = $i;
|
||||
}
|
||||
}
|
||||
if (file_path && download_url) {
|
||||
output_file_path = output_dir "/" file_path;
|
||||
print "Calling download_file for:", download_url, "to", output_file_path;
|
||||
system("'"$SCRIPT_PATH"'" " \"" download_url "\" \"" output_file_path "\"");
|
||||
}
|
||||
}
|
||||
/"type": "dir"/ {
|
||||
sub_dir = "";
|
||||
for (i = 1; i <= NF; i++) {
|
||||
if ($i ~ /"path": "/) {
|
||||
gsub(/.*"path": "/, "", $i);
|
||||
gsub(/".*/, "", $i);
|
||||
sub_dir = $i;
|
||||
}
|
||||
}
|
||||
if (sub_dir) {
|
||||
print "Calling download_github_directory for sub-directory:", sub_dir;
|
||||
system("'"$SCRIPT_PATH"'" " github \"https://github.com/" owner "/" repo "/tree/" branch "/" sub_dir "\" \"" output_dir "\"");
|
||||
}
|
||||
}'
|
||||
}
|
||||
|
||||
#if [ "$#" -eq 0 ]; then
|
||||
# echo "Usage: download <type> <url> [output_directory]"
|
||||
exit 1
|
||||
#else
|
||||
download "$@"
|
||||
#fi
|
||||
exit 0
|
||||
237
ipk-source/sdxpinn-console-menu/root/usr/bin/menu
Executable file
237
ipk-source/sdxpinn-console-menu/root/usr/bin/menu
Executable file
@@ -0,0 +1,237 @@
|
||||
#!/bin/ash
|
||||
|
||||
#WORK IN PROGRESS
|
||||
|
||||
# Define toolkit paths
|
||||
GITUSER="iamromulan"
|
||||
GITREPO="quectel-rgmii-toolkit"
|
||||
GITTREE="development-SDXPINN"
|
||||
GITMAINTREE="SDXPINN"
|
||||
GITDEVTREE="development-SDXPINN"
|
||||
|
||||
# Function to remount file system as read-write
|
||||
remount_rw() {
|
||||
mount -o remount,rw /
|
||||
}
|
||||
|
||||
# Function to remount file system as read-only
|
||||
remount_ro() {
|
||||
mount -o remount,ro /
|
||||
}
|
||||
|
||||
send_at_commands_using_atcmd() {
|
||||
while true; do
|
||||
echo -e "\e[1;32mEnter AT command (or type 'exit' to return to the main menu): \e[0m"
|
||||
read at_command
|
||||
if [ "$at_command" = "exit" ]; then
|
||||
echo -e "\e[1;32mReturning to the main menu.\e[0m"
|
||||
break
|
||||
fi
|
||||
echo -e "\e[1;32mSending AT command: $at_command\e[0m"
|
||||
echo -e "\e[1;32mResponse:\e[0m"
|
||||
# Use atcmd to send the command and display the output
|
||||
atcmd_output=$(atcmd "'$at_command'")
|
||||
echo "$atcmd_output"
|
||||
echo -e "\e[1;32m----------------------------------------\e[0m"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
||||
while true; do
|
||||
if [ ! -f "$ttl_file" ]; then
|
||||
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"
|
||||
|
||||
# Add the local ttl_firewall_file line if it's not already present
|
||||
if ! grep -q "local ttl_firewall_file" "$lan_utils_script"; then
|
||||
sed -i '/local tcpmss_firewall_filev6/a \ local ttl_firewall_file=/etc/firewall.user.ttl' "$lan_utils_script"
|
||||
fi
|
||||
|
||||
# Add the condition to include the ttl_firewall_file if it's not already present
|
||||
if (! grep -q "if \[ -f \"\$ttl_firewall_file\" \]; then" "$lan_utils_script"); then
|
||||
sed -i '/if \[ -f "\$tcpmss_firewall_filev6" \]; then/i \ if [ -f "\$ttl_firewall_file" ]; then\n cat \$ttl_firewall_file >> \$firewall_file\n fi' "$lan_utils_script"
|
||||
fi
|
||||
fi
|
||||
|
||||
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 '{for(i=1;i<=NF;i++){if($i=="--ttl-set"){print $(i+1)}}}')
|
||||
ipv6_ttl=$(grep 'ip6tables -t mangle -A POSTROUTING' "$ttl_file" | awk '{for(i=1;i<=NF;i++){if($i=="--hl-set"){print $(i+1)}}}')
|
||||
echo -e "\e[32mCurrent IPv4 TTL: $ipv4_ttl\e[0m"
|
||||
echo -e "\e[32mCurrent IPv6 TTL: $ipv6_ttl\e[0m"
|
||||
fi
|
||||
|
||||
echo -e "\e[32mWould you like to edit the TTL settings?\e[0m"
|
||||
echo -e "\e[32mTTL Value will be set without needing a reboot \e[0m"
|
||||
echo -e "\e[33mType yes or exit:\e[0m" && read -r response
|
||||
|
||||
if [ "$response" = "exit" ]; then
|
||||
echo "Exiting..."
|
||||
break
|
||||
elif [ "$response" = "yes" ]; then
|
||||
echo -e "\e[32mType 0 to disable TTL\e[0m"
|
||||
echo -e "\e[33mEnter the TTL value (number only):\e[0m" && read -r ttl_value
|
||||
if ! [[ "$ttl_value" =~ ^[0-9]+$ ]]; then
|
||||
echo "Invalid input, please enter a number."
|
||||
else
|
||||
# Clear existing TTL rules
|
||||
echo "Clearing existing TTL rules..."
|
||||
iptables -t mangle -D POSTROUTING -o rmnet+ -j TTL --ttl-set "$ipv4_ttl"
|
||||
ip6tables -t mangle -D POSTROUTING -o rmnet+ -j HL --hl-set "$ipv6_ttl"
|
||||
|
||||
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"
|
||||
iptables -t mangle -A POSTROUTING -o rmnet+ -j TTL --ttl-set $ttl_value
|
||||
ip6tables -t mangle -A POSTROUTING -o rmnet+ -j HL --hl-set $ttl_value
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
set_root_passwd() {
|
||||
passwd
|
||||
}
|
||||
|
||||
|
||||
# Function to Configure Tailscale
|
||||
configure_tailscale() {
|
||||
while true; do
|
||||
echo "Configure Tailscale"
|
||||
echo -e "\e[38;5;40m1) Enable Tailscale Web UI at http://192.168.225.1:8088 (Gateway on port 8088)\e[0m" # Green
|
||||
echo -e "\e[38;5;196m2) Disable Tailscale Web UI\e[0m" # Red
|
||||
echo -e "\e[38;5;27m3) Connect to Tailnet\e[0m" # Brown
|
||||
echo -e "\e[38;5;87m4) Connect to Tailnet with SSH ON\e[0m" # Light cyan
|
||||
echo -e "\e[38;5;105m5) Reconnect to Tailnet with SSH OFF\e[0m" # Light magenta
|
||||
echo -e "\e[38;5;172m6) Disconnect from Tailnet (reconnects at reboot)\e[0m" # Light yellow
|
||||
echo -e "\e[1;31m7) Logout from tailscale account\e[0m"
|
||||
echo -e "\e[38;5;27m8) Return to Tailscale Menu\e[0m"
|
||||
read -p "Enter your choice: " config_choice
|
||||
|
||||
case $config_choice in
|
||||
1) echo -e "\e[38;5;196mNot for the 551 yet\e[0m" ;; # Red
|
||||
2) echo -e "\e[38;5;196mNot for the 551 yet\e[0m" ;; # Red
|
||||
3) tailscale up --accept-dns=false --reset ;;
|
||||
4) tailscale up --ssh --accept-dns=false --reset ;;
|
||||
5) tailscale up --accept-dns=false --reset ;;
|
||||
6) tailscale down ;;
|
||||
7) tailscale logout ;;
|
||||
8) break ;;
|
||||
*) echo "Invalid option" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Main menu
|
||||
while true; do
|
||||
echo " .%+: "
|
||||
echo " .*@@@-. "
|
||||
echo " :@@@@- "
|
||||
echo " @@@@#. "
|
||||
echo " -@@@@#. "
|
||||
echo " :. %@@@@: -# "
|
||||
echo " .+- #@@@@%.+@- "
|
||||
echo " .#- . +@@@@# #@- "
|
||||
echo " -@*@*@% @@@@@::@@= "
|
||||
echo ".+%@@@@@@@@@%=. =@@@@# #@@- .. "
|
||||
echo " .@@@@@: :@@@@@ =@@@..%= "
|
||||
echo " -::@-.+. @@@@@.=@@@- =@- "
|
||||
echo " .@- .@@@@@:.@@@* @@. "
|
||||
echo " .%- -@@@@@:=@@@@ @@# "
|
||||
echo " .#- .%@@@@@@#. +@@@@@.#@@@@ @@@."
|
||||
echo " .*- .@@@@@@@@@@=. @@@@@@ @@@@@ @@@:"
|
||||
echo " :. .%@@@@@@@@@@@%. .@@@@@+:@@@@@ @@@-"
|
||||
echo " -@@@@@@@@@@@@@@@..@@@@@@.-@@@@@ .@@@-"
|
||||
echo " -@@@@@@@@@@%. .@@@@@@. @@@@@+ =@@@="
|
||||
echo " =@@@@@@@@* .@@@@@@. @@@@@@..@@@@-"
|
||||
echo " #@@@@@@@@-*@@@@@%..@@@@@@+ #@@@@-"
|
||||
echo " @@@@@@:.-@@@@@@. @@@@@@= %@@@@@."
|
||||
echo " .@@@@. *@@@@@@- .+@@@@@@-.@@@@@@+ "
|
||||
echo " %@@. =@@@@@*. +@@@@@@%.-@@@@@@% "
|
||||
echo " .@@ .@@@@@= :@@@@@@@@..@@@@@@@= "
|
||||
echo " =@.+@@@@@. -@@@@@@@*.:@@@@@@@*. "
|
||||
echo " %.*@@@@= .@@@@@@@-.:@@@@@@@+. "
|
||||
echo " ..@@@@= .@@@@@@: #@@@@@@@: "
|
||||
echo " .@@@@ +@@@@..%@@@@@+. "
|
||||
echo " .@@@. @@@@.:@@@@+. "
|
||||
echo " @@@. @@@. @@@* .@. "
|
||||
echo " :@@@ %@@..@@#. *@ "
|
||||
echo " -*: .@@* :@@. @@. -..@@ "
|
||||
echo " =@@@@@@.*@- :@% @* =@:=@# "
|
||||
echo " .@@@-+@@@@:%@..%- ...@%:@@: "
|
||||
echo " .@@. @@-%@: .%@@*@@%. "
|
||||
echo " :@@ :+ *@ *@@#*@@@. "
|
||||
echo " =@@@.@@@@ "
|
||||
echo " .*@@@:=@@@@: "
|
||||
echo " .@@@@:.@@@@@: "
|
||||
echo " .@@@@#.-@@@@@. "
|
||||
echo " #@@@@: =@@@@@- "
|
||||
echo " .@@@@@..@@@@@@* "
|
||||
echo " -@@@@@. @@@@@@#. "
|
||||
echo " -@@@@@ @@@@@@% "
|
||||
echo " @@@@@. #@@@@@@. "
|
||||
echo " :@@@@# =@@@@@@% "
|
||||
echo " @@@@@: @@@@@@@: "
|
||||
echo " *@@@@ @@@@@@@. "
|
||||
echo " .@@@@ @@@@@@@ "
|
||||
echo " #@@@. @@@@@@* "
|
||||
echo " @@@# @@@@@@@ "
|
||||
echo " .@@+=@@@@@@. "
|
||||
echo " *@@@@@@ "
|
||||
echo " :@@@@@= "
|
||||
echo " .@@@@@@. "
|
||||
echo " :@@@@@*. "
|
||||
echo " .=@@@@@- "
|
||||
echo " :+##+. "
|
||||
|
||||
echo -e "\e[92m"
|
||||
echo "Welcome to iamromulan's console menu for Quectel RM55x Series modems!"
|
||||
echo "Visit https://github.com/iamromulan for more!"
|
||||
echo -e "\e[0m"
|
||||
echo -e "\e[91mThis is a work in progress menu for RM550/551 modems\e[0m" # Light Red
|
||||
echo "Select an option:"
|
||||
echo -e "\e[0m"
|
||||
echo -e "\e[96m1) Send AT Commands\e[0m" # Cyan
|
||||
echo -e "\e[92m2) Run the SDXPINN toolkit\e[0m" # Green
|
||||
echo -e "\e[94m3) Run the development-SDXPINN toollkit (beta/test branch)\e[0m" # Light Blue
|
||||
echo -e "\e[94m4) TTL Settings\e[0m" # Light Blue
|
||||
echo -e "\e[94m5) Set root password\e[0m" # Light Blue
|
||||
echo -e "\e[94m6) Tailscale Management\e[0m" # Light Blue
|
||||
echo -e "\e[92m7) Run a speedtest.net speed test\e[0m" # Light Green
|
||||
echo -e "\e[93m8) Exit\e[0m" # Yellow (repeated color for exit option)
|
||||
read -p "Enter your choice: " choice
|
||||
|
||||
case $choice in
|
||||
1) send_at_commands_using_atcmd ;;
|
||||
2) cd /tmp && wget -O rcPCIe_SDXPINN_toolkit.sh https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/SDXPINN/rcPCIe_SDXPINN_toolkit.sh && chmod +x rcPCIe_SDXPINN_toolkit.sh && ./rcPCIe_SDXPINN_toolkit.sh && cd / ;;
|
||||
3) cd /tmp && wget -O rcPCIe_SDXPINN_toolkit.sh https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/development-SDXPINN/rcPCIe_SDXPINN_toolkit.sh && chmod +x rcPCIe_SDXPINN_toolkit.sh && ./rcPCIe_SDXPINN_toolkit.sh && cd / ;;
|
||||
4) ttl_setup ;;
|
||||
5) set_root_passwd ;;
|
||||
6) configure_tailscale ;;
|
||||
7) speedtest ;;
|
||||
8) echo -e "\e[1;32mGoodbye!\e[0m"; break ;;
|
||||
*) echo -e "\e[1;31mInvalid option\e[0m" ;;
|
||||
esac
|
||||
done
|
||||
Reference in New Issue
Block a user