commit
1d74cdb13f
10 changed files with 53 additions and 39 deletions
Binary file not shown.
14
helper.sh
14
helper.sh
|
@ -42,11 +42,11 @@ function update_menu() {
|
||||||
title "A new script version is available!" "${green}"
|
title "A new script version is available!" "${green}"
|
||||||
inner_line
|
inner_line
|
||||||
hr
|
hr
|
||||||
echo -e " │ ${cyan}It's recommended to keep script up to date. Updates usually ${white}│"
|
echo -e " │ ${cyan}It's recommended to keep script up to date. Updates usually ${white}│"
|
||||||
echo -e " │ ${cyan}contain bug fixes, important changes or new features. ${white}│"
|
echo -e " │ ${cyan}contain bug fixes, important changes or new features. ${white}│"
|
||||||
echo -e " │ ${cyan}Please consider updating! ${white}│"
|
echo -e " │ ${cyan}Please consider updating! ${white}│"
|
||||||
hr
|
hr
|
||||||
echo -e " │ See changelog here: ${yellow}https://tinyurl.com/3sf3bzck ${white}│"
|
echo -e " │ See changelog here: ${yellow}https://tinyurl.com/3sf3bzck ${white}│"
|
||||||
hr
|
hr
|
||||||
bottom_line
|
bottom_line
|
||||||
local yn
|
local yn
|
||||||
|
@ -55,6 +55,9 @@ function update_menu() {
|
||||||
case "${yn}" in
|
case "${yn}" in
|
||||||
Y|y)
|
Y|y)
|
||||||
run "update_helper_script"
|
run "update_helper_script"
|
||||||
|
if [ ! -x "$HELPER_SCRIPT_FOLDER"/helper.sh ]; then
|
||||||
|
chmod +x "$HELPER_SCRIPT_FOLDER"/helper.sh >/dev/null 2>&1
|
||||||
|
fi
|
||||||
break;;
|
break;;
|
||||||
N|n)
|
N|n)
|
||||||
break;;
|
break;;
|
||||||
|
@ -65,6 +68,9 @@ function update_menu() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ ! -L /usr/bin/helper ]; then
|
||||||
|
ln -sf "$HELPER_SCRIPT_FOLDER"/helper.sh /usr/bin/helper > /dev/null 2>&1
|
||||||
|
fi
|
||||||
rm -rf /root/.cache
|
rm -rf /root/.cache
|
||||||
set_paths
|
set_paths
|
||||||
set_permissions
|
set_permissions
|
||||||
|
|
|
@ -170,7 +170,7 @@ function install_menu_3ke() {
|
||||||
elif [ ! -f "$ENTWARE_FILE" ]; then
|
elif [ ! -f "$ENTWARE_FILE" ]; then
|
||||||
error_msg "Entware is needed, please install it first!"
|
error_msg "Entware is needed, please install it first!"
|
||||||
else
|
else
|
||||||
run "install_moonraker_obico" "install_menu_ui_3ke"
|
run "disabled_feature" "install_menu_ui_3ke"
|
||||||
fi;;
|
fi;;
|
||||||
16)
|
16)
|
||||||
if [ ! -d "$MOONRAKER_FOLDER" ] && [ ! -d "$NGINX_FOLDER" ]; then
|
if [ ! -d "$MOONRAKER_FOLDER" ] && [ ! -d "$NGINX_FOLDER" ]; then
|
||||||
|
|
|
@ -188,7 +188,7 @@ function install_menu_3v3() {
|
||||||
elif [ ! -f "$ENTWARE_FILE" ]; then
|
elif [ ! -f "$ENTWARE_FILE" ]; then
|
||||||
error_msg "Entware is needed, please install it first!"
|
error_msg "Entware is needed, please install it first!"
|
||||||
else
|
else
|
||||||
run "install_moonraker_obico" "install_menu_ui_3v3"
|
run "disabled_feature" "install_menu_ui_3v3"
|
||||||
fi;;
|
fi;;
|
||||||
18)
|
18)
|
||||||
if [ ! -d "$MOONRAKER_FOLDER" ]; then
|
if [ ! -d "$MOONRAKER_FOLDER" ]; then
|
||||||
|
|
|
@ -207,7 +207,7 @@ function install_menu_k1() {
|
||||||
elif [ ! -f "$ENTWARE_FILE" ]; then
|
elif [ ! -f "$ENTWARE_FILE" ]; then
|
||||||
error_msg "Entware is needed, please install it first!"
|
error_msg "Entware is needed, please install it first!"
|
||||||
else
|
else
|
||||||
run "install_moonraker_obico" "install_menu_ui_k1"
|
run "disabled_feature" "install_menu_ui_k1"
|
||||||
fi;;
|
fi;;
|
||||||
21)
|
21)
|
||||||
if [ ! -d "$MOONRAKER_FOLDER" ] && [ ! -d "$NGINX_FOLDER" ]; then
|
if [ ! -d "$MOONRAKER_FOLDER" ] && [ ! -d "$NGINX_FOLDER" ]; then
|
||||||
|
|
|
@ -4,19 +4,19 @@ set -e
|
||||||
|
|
||||||
function top_line() {
|
function top_line() {
|
||||||
echo -e "${white}"
|
echo -e "${white}"
|
||||||
echo -e " ┌──────────────────────────────────────────────────────────────┐"
|
echo -e " ┌────────────────────────────────────────────────────────────────┐"
|
||||||
}
|
}
|
||||||
|
|
||||||
function hr() {
|
function hr() {
|
||||||
echo -e " │ │"
|
echo -e " │ │"
|
||||||
}
|
}
|
||||||
|
|
||||||
function inner_line() {
|
function inner_line() {
|
||||||
echo -e " ├──────────────────────────────────────────────────────────────┤"
|
echo -e " ├────────────────────────────────────────────────────────────────┤"
|
||||||
}
|
}
|
||||||
|
|
||||||
function bottom_line() {
|
function bottom_line() {
|
||||||
echo -e " └──────────────────────────────────────────────────────────────┘"
|
echo -e " └────────────────────────────────────────────────────────────────┘"
|
||||||
echo -e "${white}"
|
echo -e "${white}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ function blank_line() {
|
||||||
function title() {
|
function title() {
|
||||||
local text=$1
|
local text=$1
|
||||||
local color=$2
|
local color=$2
|
||||||
local max_length=62
|
local max_length=64
|
||||||
local text_length=${#text}
|
local text_length=${#text}
|
||||||
local padding_left=$(((max_length - text_length) / 2))
|
local padding_left=$(((max_length - text_length) / 2))
|
||||||
local padding_right=$((max_length - text_length - padding_left))
|
local padding_right=$((max_length - text_length - padding_left))
|
||||||
|
@ -36,7 +36,7 @@ function title() {
|
||||||
|
|
||||||
function subtitle() {
|
function subtitle() {
|
||||||
local menu_text1=$1
|
local menu_text1=$1
|
||||||
local max_length=61
|
local max_length=63
|
||||||
local padding=$((max_length - ${#menu_text1}))
|
local padding=$((max_length - ${#menu_text1}))
|
||||||
printf " │ ${blue}${menu_text1}%-${padding}s${white}│\n" ''
|
printf " │ ${blue}${menu_text1}%-${padding}s${white}│\n" ''
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ function main_menu_option() {
|
||||||
local menu_number=$1
|
local menu_number=$1
|
||||||
local menu_text1=$2
|
local menu_text1=$2
|
||||||
local menu_text2=$3
|
local menu_text2=$3
|
||||||
local max_length=56
|
local max_length=58
|
||||||
local total_text_length=$(( ${#menu_text1} + ${#menu_text2} ))
|
local total_text_length=$(( ${#menu_text1} + ${#menu_text2} ))
|
||||||
local padding=$((max_length - total_text_length))
|
local padding=$((max_length - total_text_length))
|
||||||
printf " │ ${yellow}${menu_number}${white}) ${green}${menu_text1} ${white}${menu_text2}%-${padding}s${white}│\n" ''
|
printf " │ ${yellow}${menu_number}${white}) ${green}${menu_text1} ${white}${menu_text2}%-${padding}s${white}│\n" ''
|
||||||
|
@ -55,7 +55,7 @@ function menu_option() {
|
||||||
local menu_number=$1
|
local menu_number=$1
|
||||||
local menu_text1=$2
|
local menu_text1=$2
|
||||||
local menu_text2=$3
|
local menu_text2=$3
|
||||||
local max_length=60
|
local max_length=62
|
||||||
local total_text_length=$(( ${#menu_text1} + ${#menu_text2} + ${#menu_number} + 4 ))
|
local total_text_length=$(( ${#menu_text1} + ${#menu_text2} + ${#menu_number} + 4 ))
|
||||||
local padding=$((max_length - total_text_length))
|
local padding=$((max_length - total_text_length))
|
||||||
printf " │ ${yellow}${menu_number}${white}) ${white}${menu_text1} ${green}${menu_text2}%-${padding}s${white}│\n" ''
|
printf " │ ${yellow}${menu_number}${white}) ${white}${menu_text1} ${green}${menu_text2}%-${padding}s${white}│\n" ''
|
||||||
|
@ -65,7 +65,7 @@ function bottom_menu_option() {
|
||||||
local menu_number=$1
|
local menu_number=$1
|
||||||
local menu_text=$2
|
local menu_text=$2
|
||||||
local color=$3
|
local color=$3
|
||||||
local max_length=57
|
local max_length=59
|
||||||
local padding=$((max_length - ${#menu_text}))
|
local padding=$((max_length - ${#menu_text}))
|
||||||
printf " │ $color${menu_number}${white}) ${white}${menu_text}%-${padding}s${white}│\n" ''
|
printf " │ $color${menu_number}${white}) ${white}${menu_text}%-${padding}s${white}│\n" ''
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ function info_line() {
|
||||||
local status=$1
|
local status=$1
|
||||||
local text=$2
|
local text=$2
|
||||||
local color=$3
|
local color=$3
|
||||||
local max_length=66
|
local max_length=68
|
||||||
local total_text_length=$(( ${#status} + ${#text} ))
|
local total_text_length=$(( ${#status} + ${#text} ))
|
||||||
local padding=$((max_length - total_text_length))
|
local padding=$((max_length - total_text_length))
|
||||||
printf " │ $color${status} ${white}${text}%-${padding}s${white}│\n" ''
|
printf " │ $color${status} ${white}${text}%-${padding}s${white}│\n" ''
|
||||||
|
@ -83,7 +83,7 @@ function info_line() {
|
||||||
function system_line() {
|
function system_line() {
|
||||||
local title="$1"
|
local title="$1"
|
||||||
local value="$2"
|
local value="$2"
|
||||||
local max_length=61
|
local max_length=63
|
||||||
local title_length=${#title}
|
local title_length=${#title}
|
||||||
local separator=": "
|
local separator=": "
|
||||||
local value_length=${#value}
|
local value_length=${#value}
|
||||||
|
|
|
@ -30,7 +30,7 @@ function get_script_version() {
|
||||||
function version_line() {
|
function version_line() {
|
||||||
local content="$1"
|
local content="$1"
|
||||||
local content_length="${#content}"
|
local content_length="${#content}"
|
||||||
local width=$((73))
|
local width=$((75))
|
||||||
local padding_length=$((width - content_length - 3))
|
local padding_length=$((width - content_length - 3))
|
||||||
printf " │ %*s%s%s\n" $padding_length '' "$content" " │"
|
printf " │ %*s%s%s\n" $padding_length '' "$content" " │"
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,29 @@ function check_connection() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function format_uptime() {
|
||||||
|
local uptime=$1
|
||||||
|
local upDays=$((uptime / 60 / 60 / 24))
|
||||||
|
local upHours=$((uptime / 60 / 60 % 24))
|
||||||
|
local upMins=$((uptime / 60 % 60))
|
||||||
|
local output=""
|
||||||
|
if [ $upDays -gt 0 ]; then
|
||||||
|
output="$output$upDays day"
|
||||||
|
[ $upDays -gt 1 ] && output="${output}s"
|
||||||
|
output="$output "
|
||||||
|
fi
|
||||||
|
if [ $upHours -gt 0 ]; then
|
||||||
|
output="$output$upHours hour"
|
||||||
|
[ $upHours -gt 1 ] && output="${output}s"
|
||||||
|
output="$output "
|
||||||
|
fi
|
||||||
|
if [ $upMins -gt 0 ] || [ -z "$output" ]; then
|
||||||
|
output="$output$upMins minute"
|
||||||
|
[ $upMins -gt 1 ] && output="${output}s"
|
||||||
|
fi
|
||||||
|
echo "$output"
|
||||||
|
}
|
||||||
|
|
||||||
function system_menu_ui() {
|
function system_menu_ui() {
|
||||||
memfree=`cat /proc/meminfo | grep MemFree | awk {'print $2'}`
|
memfree=`cat /proc/meminfo | grep MemFree | awk {'print $2'}`
|
||||||
memtotal=`cat /proc/meminfo | grep MemTotal | awk {'print $2'}`
|
memtotal=`cat /proc/meminfo | grep MemTotal | awk {'print $2'}`
|
||||||
|
@ -30,10 +53,8 @@ function system_menu_ui() {
|
||||||
diskused=`df -h | grep /dev/mmcblk0p10 | awk {'print $3 " / " $2 " (" $4 " available)" '}`
|
diskused=`df -h | grep /dev/mmcblk0p10 | awk {'print $3 " / " $2 " (" $4 " available)" '}`
|
||||||
process=`ps ax | wc -l | tr -d " "`
|
process=`ps ax | wc -l | tr -d " "`
|
||||||
uptime=`cat /proc/uptime | cut -f1 -d.`
|
uptime=`cat /proc/uptime | cut -f1 -d.`
|
||||||
upDays=$((uptime/60/60/24))
|
formatted_uptime=$(format_uptime $uptime)
|
||||||
upHours=$((uptime/60/60%24))
|
load=`awk -v cpus=2 '{printf "%.2f%% (1 min) | %.2f%% (5 min) | %.2f%% (15 min)\n", $1*100/cpus, $2*100/cpus, $3*100/cpus}' /proc/loadavg`
|
||||||
upMins=$((uptime/60%60))
|
|
||||||
load=`cat /proc/loadavg | awk {'print $1 " (1 min.) / " $2 " (5 min.) / " $3 " (15 min.)"'}`
|
|
||||||
device_sn=$(cat /usr/data/creality/userdata/config/system_config.json | grep -o '"device_sn":"[^"]*' | awk -F '"' '{print $4}')
|
device_sn=$(cat /usr/data/creality/userdata/config/system_config.json | grep -o '"device_sn":"[^"]*' | awk -F '"' '{print $4}')
|
||||||
mac_address=$(cat /usr/data/creality/userdata/config/system_config.json | grep -o '"device_mac":"[^"]*' | awk -F '"' '{print $4}' | sed 's/../&:/g; s/:$//')
|
mac_address=$(cat /usr/data/creality/userdata/config/system_config.json | grep -o '"device_mac":"[^"]*' | awk -F '"' '{print $4}' | sed 's/../&:/g; s/:$//')
|
||||||
top_line
|
top_line
|
||||||
|
@ -46,11 +67,10 @@ function system_menu_ui() {
|
||||||
system_line " Device SN" "$device_sn"
|
system_line " Device SN" "$device_sn"
|
||||||
system_line " IP Address" "$(check_connection)"
|
system_line " IP Address" "$(check_connection)"
|
||||||
system_line "MAC Address" "$mac_address"
|
system_line "MAC Address" "$mac_address"
|
||||||
|
system_line " CPU Usage" "$load"
|
||||||
system_line " RAM Usage" "$(($memfree/1024)) MB / $(($memtotal/1024)) MB ($pourcent% available)"
|
system_line " RAM Usage" "$(($memfree/1024)) MB / $(($memtotal/1024)) MB ($pourcent% available)"
|
||||||
system_line " Disk Usage" "$diskused"
|
system_line " Disk Usage" "$diskused"
|
||||||
system_line " Uptime" "$upDays days $upHours hours $upMins minutes"
|
system_line " Uptime" "$formatted_uptime"
|
||||||
system_line " Processes" "$process running process"
|
|
||||||
system_line "System Load" "$load"
|
|
||||||
hr
|
hr
|
||||||
inner_line
|
inner_line
|
||||||
hr
|
hr
|
||||||
|
|
|
@ -70,9 +70,6 @@ function install_moonraker_nginx(){
|
||||||
chmod 755 "$SYSTEMCTL_URL"
|
chmod 755 "$SYSTEMCTL_URL"
|
||||||
ln -sf "$SUDO_URL" "$SUDO_FILE"
|
ln -sf "$SUDO_URL" "$SUDO_FILE"
|
||||||
ln -sf "$SYSTEMCTL_URL" "$SYSTEMCTL_FILE"
|
ln -sf "$SYSTEMCTL_URL" "$SYSTEMCTL_FILE"
|
||||||
echo -e "Info: Installing necessary packages..."
|
|
||||||
cd "$MOONRAKER_FOLDER"/moonraker-env/bin
|
|
||||||
python3 -m pip install --no-cache-dir pyserial-asyncio==0.6
|
|
||||||
echo -e "Info: Starting Nginx service..."
|
echo -e "Info: Starting Nginx service..."
|
||||||
start_nginx
|
start_nginx
|
||||||
echo -e "Info: Starting Moonraker service..."
|
echo -e "Info: Starting Moonraker service..."
|
||||||
|
@ -100,9 +97,6 @@ function remove_moonraker_nginx(){
|
||||||
stop_moonraker
|
stop_moonraker
|
||||||
stop_nginx
|
stop_nginx
|
||||||
echo -e "Info: Removing files..."
|
echo -e "Info: Removing files..."
|
||||||
cd "$MOONRAKER_FOLDER"/moonraker-env/bin
|
|
||||||
python3 -m pip uninstall -y pyserial-asyncio==0.6
|
|
||||||
cd
|
|
||||||
rm -f "$INITD_FOLDER"/S50nginx
|
rm -f "$INITD_FOLDER"/S50nginx
|
||||||
rm -f "$INITD_FOLDER"/S56moonraker_service
|
rm -f "$INITD_FOLDER"/S56moonraker_service
|
||||||
rm -f "$KLIPPER_CONFIG_FOLDER"/moonraker.conf
|
rm -f "$KLIPPER_CONFIG_FOLDER"/moonraker.conf
|
||||||
|
@ -176,9 +170,6 @@ function install_moonraker_3v3(){
|
||||||
chmod 755 "$SYSTEMCTL_URL"
|
chmod 755 "$SYSTEMCTL_URL"
|
||||||
ln -sf "$SUDO_URL" "$SUDO_FILE"
|
ln -sf "$SUDO_URL" "$SUDO_FILE"
|
||||||
ln -sf "$SYSTEMCTL_URL" "$SYSTEMCTL_FILE"
|
ln -sf "$SYSTEMCTL_URL" "$SYSTEMCTL_FILE"
|
||||||
echo -e "Info: Installing necessary packages..."
|
|
||||||
cd "$MOONRAKER_FOLDER"/moonraker-env/bin
|
|
||||||
python3 -m pip install --no-cache-dir pyserial-asyncio==0.6
|
|
||||||
echo -e "Info: Starting Nginx service..."
|
echo -e "Info: Starting Nginx service..."
|
||||||
start_nginx
|
start_nginx
|
||||||
echo -e "Info: Starting Moonraker service..."
|
echo -e "Info: Starting Moonraker service..."
|
||||||
|
@ -206,9 +197,6 @@ function remove_moonraker_3v3(){
|
||||||
stop_moonraker
|
stop_moonraker
|
||||||
stop_nginx
|
stop_nginx
|
||||||
echo -e "Info: Removing files..."
|
echo -e "Info: Removing files..."
|
||||||
cd "$MOONRAKER_FOLDER"/moonraker-env/bin
|
|
||||||
python3 -m pip uninstall -y pyserial-asyncio==0.6
|
|
||||||
cd
|
|
||||||
rm -rf "$PRINTER_DATA_FOLDER"/comms
|
rm -rf "$PRINTER_DATA_FOLDER"/comms
|
||||||
rm -rf "$MOONRAKER_FOLDER"
|
rm -rf "$MOONRAKER_FOLDER"
|
||||||
rm -f "$KLIPPER_CONFIG_FOLDER"/moonraker.conf
|
rm -f "$KLIPPER_CONFIG_FOLDER"/moonraker.conf
|
||||||
|
|
|
@ -99,7 +99,7 @@ function set_paths() {
|
||||||
|
|
||||||
# Improved Shapers Calibrations #
|
# Improved Shapers Calibrations #
|
||||||
IMP_SHAPERS_FOLDER="${HS_CONFIG_FOLDER}/improved-shapers"
|
IMP_SHAPERS_FOLDER="${HS_CONFIG_FOLDER}/improved-shapers"
|
||||||
IMP_SHAPERS_URL="${HS_FILES}/improved-shapers/"
|
IMP_SHAPERS_URL="${HS_FILES}/improved-shapers"
|
||||||
|
|
||||||
# Useful Macros #
|
# Useful Macros #
|
||||||
USEFUL_MACROS_FILE="${HS_CONFIG_FOLDER}/useful-macros.cfg"
|
USEFUL_MACROS_FILE="${HS_CONFIG_FOLDER}/useful-macros.cfg"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue