-## "The Script" version May 12, 2020 updates reference to http://tech.scargill.net to the https version,
-## adds "micro" editor, improves remote root access and fixes/improves basic web page, removes DarkSky node
+## "The Script" version May 13, 2020 updates reference to http://tech.scargill.net to the https version,
+## improves remote root access and fixes/improves basic web page, removes DarkSky node and adds in the MICRO editor
## December 19 2019 fixed a connection check
## Previous updates includes changes to handle Raspbian Buster, RPi4 and other recent changes
## including the latest Node/Node-Red updates (at this time v1.0.2) on Raspbian
## and the full version works just as well)
## See also: BigTimer, ESP-GO and other included Node-Red nodes of mine
-## Many thanks to Antonio (Mr Shark) for his work.
+## Many thanks to Antonio (Mr Shark) for his help.
## Mosquitto (port 1883) with web sockets (Port 9001)
## SQLITE ( xxx.xxx.xxx.xxx/phpliteadmin),
#############################################################################
-printstatus "Welcome to THE SCRIPT!"
+printstatus "Welcome to 'The Script'"
- sudo touch /etc/AlreadyRun
+ if [[ $OPSYS != *"RASPBIAN"* ]]; then
+ sudo touch /etc/AlreadyRun
if [ ! -f /etc/AlreadyRun ]; then
printstatus "Allow remote root login and speed up SSH"
- sudo sed -i -e 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config
- sudo sed -i -e 's/PermitRootLogin without-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
- sudo sed -i -e 's/PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
sudo sed -i -e 's/#PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config
sudo sed -i -e 's/#PermitRootLogin without-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
sudo sed -i -e 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
+ sudo sed -i -e 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config
+ sudo sed -i -e 's/PermitRootLogin without-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
+ sudo sed -i -e 's/PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
sudo sed -i -e 's/TCPKeepAlive yes/TCPKeepAlive no/g' /etc/ssh/sshd_config
sudo sed -i '$ a UseDNS no' /etc/ssh/sshd_config
sudo sed -i '$ a ClientAliveInterval 30' /etc/ssh/sshd_config
sudo apt-get install avahi-daemon avahi-utils -y 2>&1 | tee -a $LOGFILE
sudo sed -i -e 's/use-ipv6=yes/use-ipv6=no/g' /etc/avahi/avahi-daemon.conf
- printstatus "Script is re-running, avoiding un-necessary repeats"
+ printstatus "'The Script' is re-running, avoiding un-necessary repeats"
if [[ $OPSYS == "LINUXMINT" ]]; then
if [[ $OPSYS == *"RASPBIAN"* ]];then
- MYMENU=$(whiptail --title "Main Raspberry Pi Selection" --checklist \
- "\nSelect items for your Pi as required then hit OK" 28 73 21 \
+ MYMENU=$(whiptail --title "Peter Scargill's 'The Script' Main Menu for Raspberry Pi" --checklist \
+ "\n Make your selections (SPACE) as required then TAB to OK/Cancel" 28 73 19 \
"quiet" "Quiet(er) install - untick for lots of info " ON \
"prereq" "Install general pre-requisites " ON \
"mosquitto" "Install Mosquitto" ON \
"apache" "Install Apache/PHP/SQLITE + PHPLITEADMIN " ON \
- "nodenew" "Install NodeJS and NodeRed (NEW)" ON \
- "nodejs" "Install NodeJS" OFF \
- "nodered" "Install Node-Red" OFF \
+ "nodenew" "Install NodeJS and NodeRed (Raspberry Pi)" ON \
"webmin" "Install Webmin" OFF \
"java" "Update Java" OFF \
"hwsupport" "Enable support for Serial, I2C, GPIO, etc" OFF \
"wiringpi" "Wiring Pi for the GPIO utility" OFF \
"phpsysinfo" "Install PHPSYSYINFO" ON \
"modpass" "Mod USER and ADMIN passwords (password123)" ON \
- "addindex" "Add an index page and some CSS" ON \
+ "addindex" "Add a basic index page and CSS" ON \
"passwords" "Update ROOT and PI user passwords" OFF \
"habridge" "Install HA-bridge on port 82" OFF \
"rpiclone" "Install RPI-Clone" ON \
"log2ram" "Install Log2RAM default 40 Meg" OFF \
- "grafana" "Install Grafana and InfluxDB" OFF \
- "wolfram" "Remove Wolfram on a PI to save space" OFF \
+ "grafana" "Install Grafana and InfluxDB" OFF \
+ "wolfram" "Remove Wolfram on a PI to save space" OFF \
"office" "Remove LibreOffice on PI to save space" OFF 3>&1 1>&2 2>&3)
- MYMENU=$(whiptail --title "Main Non-Pi Selection" --checklist \
- "\nSelect items as required then hit OK" 30 73 23 \
+ MYMENU=$(whiptail --title "Peter Scargill's 'The Script' Main Non-Pi Menu" --checklist \
+ "\n Make your selections (SPACE) as required then TAB to OK/Cancel" 29 73 21 \
"quiet" "Quiet(er) install - untick for lots of info " ON \
"prereq" "Install general pre-requisites" ON \
"mosquitto" "Install Mosquitto" ON \
"habridge" "Install HA-bridge on port 82" OFF \
"rpiclone" "Install RPI-Clone" ON \
"log2ram" "Install Log2RAM default 40Meg" OFF \
- "grafana" "Install Grafana and InfluxDB" OFF 3>&1 1>&2 2>&3)
+ "grafana" "Install Grafana and InfluxDB" OFF 3>&1 1>&2 2>&3)
if [[ $MYMENU != *"quiet"* ]]; then
-curl -s https://getmic.ro | bash
-sudo apt install xclip -qq
+curl $NQUIET https://getmic.ro | bash
+sudo apt install $AQUIET -y xclip
sudo rm -rf /var/cache/apt/archives/apt-fast
-sudo apt-get $AQUIET -y clean 2>&1 | tee -a $LOGFILE
+sudo apt-get $AQUIET -y clean 2>&1 | tee -a $LOGFILE
echo $newhostname | sudo tee /etc/hostname > /dev/null 2>&1
sudo sed -i '/^127.0.1.1/ d' /etc/hosts > /dev/null 2>&1
echo 127.0.1.1 $newhostname | sudo tee -a /etc/hosts > /dev/null 2>&1
-sudo /etc/init.d/hostname.sh > /dev/null 2>&1
+#sudo /etc/init.d/hostname.sh > /dev/null 2>&1
#printstatus "Installing Glances"
#sudo apt-get -y install python{,3}-setuptools 2>&1 | tee -a $LOGFILE
sudo grep -h ^deb /etc/apt/sources.list /etc/apt/sources.list.d/* 2>&1 >> $LOGFILE
echo "alias space='df -h|grep -v udev|grep -v tmpfs|grep -v run'" | sudo tee -a /etc/bash.bashrc > /dev/null 2>&1
+if [ ! -f /home/pi/AlreadyBashed ]; then
+sudo touch /home/pi/AlreadyBashed
+sudo tee -a /etc/bash.bashrc > /dev/null <<EOT
+PS1="\[\033[38;5;39m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\]@\[$(tput sgr0)\]\[\033[38;5;222m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sgr0)\]\[\033[38;5;83m\]\W\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sgr0)\]\[\033[38;5;69m\]\A\[$(tput sgr0)\]\[\033[38;5;15m\][\[$(tput sgr0)\]\[\033[38;5;174m\]\$?\[$(tput sgr0)\]\[\033[38;5;15m\]]> \[$(tput sgr0)\]"
+LIGHTPURPLE='\033[1;35m'
+alias mqttlog='tail -f /var/log/mosquitto/mosquitto.log | ccze -A'
+alias nrlog='sudo journalctl -f -n 50 -u nodered -o cat | ccze -A'
+alias space='df -h|grep -v udev|grep -v tmpfs|grep -v run'
+alias cls='python /home/pi/cls.py'
+alias stop='sudo shutdown now'
+alias boot='sudo reboot'
+alias partitions='cat /proc/partitions'
+alias parts='sudo fdisk -l /dev/mmc* /dev/sd*'
+alias cloned="sudo printf 'Last cloned on ' && sudo tune2fs -l /dev/sda2|grep -i write|grep -iv life|cut -d: -f 2-|xargs"
+#optional hostnames in 4 functions below
+printf "${LIGHTBLUE}Creating a quick clone on SDA${NC}\n"
+touch /home/pi/clone-date
+bashCmd=(sudo rpi-clone -U sda)
+printf "${LIGHTRED}Creating a full clone on SDA${NC}\n"
+touch /home/pi/clone-date
+bashCmd=(sudo rpi-clone -f -U sda)
+printf "${LIGHTBLUE}Creating a quick clone on SDB${NC}\n"
+touch /home/pi/clone-date
+bashCmd=(sudo rpi-clone -U sdb)
+printf "${LIGHTRED}Creating a full clone on SDB${NC}\n"
+touch /home/pi/clone-date
+bashCmd=(sudo rpi-clone -f -U sdb)
+printf "${LIGHTGREEN}Getting upgrades...${NC}"
+printf "${LIGHTGREEN}This setup was created at ${YELLOW}"
+bashCmd=(date -r /home/pi/clone-date +"%H:%M on %-d/%m/%Y")
+sudo tee -a /etc/profile > /dev/null <<EOT
+export MICRO_TRUECOLOR=1
-printstatus "ALL DONE - PLEASE REBOOT NOW THEN TEST"
+printstatus "COMPLETE - PLEASE REBOOT NOW THEN TEST"