2022-02-19 00:31:06 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/node-red-themes.sh)"
|
|
|
|
set -o errexit
|
2022-10-30 01:04:45 +00:00
|
|
|
show_menu() {
|
|
|
|
YW=$(echo "\033[33m")
|
|
|
|
RD=$(echo "\033[01;31m")
|
|
|
|
BL=$(echo "\033[36m")
|
2022-02-19 00:31:06 +00:00
|
|
|
CM='\xE2\x9C\x94\033'
|
2022-10-30 01:04:45 +00:00
|
|
|
GN=$(echo "\033[1;92m")
|
|
|
|
CL=$(echo "\033[m")
|
|
|
|
echo -e "${RD} Backup your Node-Red flows before running this script!!${CL} \n "
|
|
|
|
while true; do
|
|
|
|
read -p "This will Install Node-Red Themes. Proceed(y/n)?" yn
|
|
|
|
case $yn in
|
|
|
|
[Yy]*) break ;;
|
|
|
|
[Nn]*) exit ;;
|
|
|
|
*) echo "Please answer yes or no." ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
clear
|
|
|
|
echo -e "${RD} Backup your Node-Red flows before installing any theme!!${CL} \n "
|
2022-02-19 00:31:06 +00:00
|
|
|
printf "\n${BL}*********************************************${CL}\n"
|
2022-02-19 02:51:12 +00:00
|
|
|
printf "${BL}**${YW} 1)${GN} Default Theme ${CL}\n"
|
|
|
|
printf "${BL}**${YW} 2)${GN} Dark Theme ${CL}\n"
|
|
|
|
printf "${BL}**${YW} 3)${GN} Dracula Theme ${CL}\n"
|
|
|
|
printf "${BL}**${YW} 4)${GN} Midnight-Red Theme ${CL}\n"
|
|
|
|
printf "${BL}**${YW} 5)${GN} Oled Theme ${CL}\n"
|
|
|
|
printf "${BL}**${YW} 6)${GN} Solarized-Dark Theme ${CL}\n"
|
|
|
|
printf "${BL}**${YW} 7)${GN} Solarized-Light Theme ${CL}\n"
|
2022-02-19 00:31:06 +00:00
|
|
|
printf "${BL}*********************************************${CL}\n"
|
|
|
|
printf "Please choose a theme from the menu and enter or ${RD}x to exit. ${CL}"
|
|
|
|
read opt
|
|
|
|
}
|
|
|
|
|
2022-10-30 01:04:45 +00:00
|
|
|
option_picked() {
|
|
|
|
msgcolor=$(echo "\033[01;31m")
|
|
|
|
normal=$(echo "\033[00;00m")
|
2022-02-19 00:31:06 +00:00
|
|
|
message=${@:-"${CL}Error: No message passed"}
|
|
|
|
printf "${RD}${message}${CL}\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
clear
|
|
|
|
show_menu
|
2022-10-30 01:04:45 +00:00
|
|
|
while [ "$opt" != " " ]; do
|
|
|
|
case $opt in
|
|
|
|
1)
|
|
|
|
clear
|
|
|
|
option_picked "Installing Default Theme"
|
|
|
|
THEME=
|
|
|
|
JS=//
|
|
|
|
break
|
2022-02-19 02:51:12 +00:00
|
|
|
;;
|
2022-10-30 01:04:45 +00:00
|
|
|
2)
|
|
|
|
clear
|
|
|
|
option_picked "Installing Dark Theme"
|
|
|
|
THEME=dark
|
|
|
|
break
|
2022-02-19 00:31:06 +00:00
|
|
|
;;
|
2022-10-30 01:04:45 +00:00
|
|
|
3)
|
|
|
|
clear
|
|
|
|
option_picked "Installing Dracula Theme"
|
|
|
|
THEME=dracula
|
|
|
|
break
|
2022-02-19 00:31:06 +00:00
|
|
|
;;
|
2022-10-30 01:04:45 +00:00
|
|
|
4)
|
|
|
|
clear
|
|
|
|
option_picked "Installing Midnight-Red Theme"
|
|
|
|
THEME=midnight-red
|
|
|
|
break
|
2022-02-19 00:31:06 +00:00
|
|
|
;;
|
2022-10-30 01:04:45 +00:00
|
|
|
5)
|
|
|
|
clear
|
|
|
|
option_picked "Installing Oled Theme"
|
|
|
|
THEME=oled
|
|
|
|
break
|
2022-02-19 00:31:06 +00:00
|
|
|
;;
|
2022-10-30 01:04:45 +00:00
|
|
|
6)
|
|
|
|
clear
|
|
|
|
option_picked "Installing Solarized-Dark Theme"
|
|
|
|
THEME=solarized-dark
|
|
|
|
break
|
2022-02-19 00:31:06 +00:00
|
|
|
;;
|
2022-10-30 01:04:45 +00:00
|
|
|
7)
|
|
|
|
clear
|
|
|
|
option_picked "Installing Solarized-Light Theme"
|
|
|
|
THEME=solarized-light
|
|
|
|
break
|
2022-02-19 00:31:06 +00:00
|
|
|
;;
|
|
|
|
|
2022-10-30 01:04:45 +00:00
|
|
|
x)
|
|
|
|
exit
|
2022-02-19 00:31:06 +00:00
|
|
|
;;
|
2022-10-30 01:04:45 +00:00
|
|
|
\n)
|
|
|
|
exit
|
2022-02-19 00:31:06 +00:00
|
|
|
;;
|
2022-10-30 01:04:45 +00:00
|
|
|
*)
|
|
|
|
clear
|
|
|
|
option_picked "Please choose a theme from the menu"
|
|
|
|
show_menu
|
2022-02-19 00:31:06 +00:00
|
|
|
;;
|
2022-10-30 01:04:45 +00:00
|
|
|
esac
|
|
|
|
done
|
2022-02-19 00:31:06 +00:00
|
|
|
echo -en "${GN} Installing ${THEME} Theme... "
|
|
|
|
cd /root/.node-red
|
2022-02-19 02:51:12 +00:00
|
|
|
if [ "${THEME}" = "" ]; then
|
2022-10-30 01:04:45 +00:00
|
|
|
echo -e "${CM}${CL} \r"
|
|
|
|
else
|
|
|
|
npm install @node-red-contrib-themes/${THEME} &>/dev/null
|
|
|
|
echo -e "${CM}${CL} \r"
|
2022-02-19 02:51:12 +00:00
|
|
|
fi
|
2022-02-19 00:31:06 +00:00
|
|
|
echo -en "${GN} Writing Settings... "
|
2022-10-30 01:04:45 +00:00
|
|
|
cat <<EOF >/root/.node-red/settings.js
|
2022-02-19 00:31:06 +00:00
|
|
|
module.exports = { uiPort: process.env.PORT || 1880,
|
|
|
|
mqttReconnectTime: 15000,
|
|
|
|
serialReconnectTime: 15000,
|
|
|
|
debugMaxLength: 1000,
|
|
|
|
functionGlobalContext: {
|
|
|
|
},
|
|
|
|
exportGlobalContextKeys: false,
|
|
|
|
|
|
|
|
// Configure the logging output
|
|
|
|
logging: {
|
|
|
|
console: {
|
|
|
|
level: "info",
|
|
|
|
metrics: false,
|
|
|
|
audit: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Customising the editor
|
|
|
|
editorTheme: {
|
2022-02-19 02:51:12 +00:00
|
|
|
${JS}theme: "${THEME}"
|
2022-02-19 00:31:06 +00:00
|
|
|
},
|
|
|
|
projects: {
|
|
|
|
// To enable the Projects feature, set this value to true
|
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
echo -e "${CM}${CL} \r"
|
|
|
|
|
|
|
|
echo -en "${GN} Restarting Node-Red... "
|
|
|
|
echo -e "${CM}${CL} \r"
|
2022-10-23 19:36:16 +00:00
|
|
|
systemctl restart nodered
|
2022-02-19 00:31:06 +00:00
|
|
|
echo -en "${GN} Finished... ${CL} \n"
|
|
|
|
exit
|