Snippets

Peter Scargill "The Script"

Updated by Peter Scargill

File script.sh Modified

  • Ignore whitespace
  • Hide word diff
 if [[ $MYMENU == *"nodenew"* ]]; then
     printstatus "Installing NodeJS and NodeRed"
 	
-##  bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
-   
-    curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered > update-nodejs-and-nodered
+	##  bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
+ 
+  	curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered > update-nodejs-and-nodered
+ 
+   	##  curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered > update-nodejs-and-nodered
     echo 143.204.15.127 deb.nodesource.com | sudo tee -a /etc/hosts
     chmod +x update-nodejs-and-nodered
     echo y | ./update-nodejs-and-nodered
Updated by Peter Scargill

File script.sh Modified

  • Ignore whitespace
  • Hide word diff
 ##
 ## We cannot answer questions on board/operating system combinations we have not tested. See notes below for tested combos and dates.
 ## 
+## 24/05/2020 - Fix for extra tabs on PI Cockpit addition - thanks to Dominic
 ## 23/05/2020 - added cockpit as option in RPI
 ## 16/05/2020 - note at this time the "micro" editor still has cut and paste issues - consider grabbing the latest nightly build and overwriting the /home/pi/micro file
 ##  Example only:
         "rpiclone" "Install RPI-Clone" ON \
         "log2ram" "Install Log2RAM default 40 Meg" OFF \
 		"grafana" "Install Grafana and InfluxDB" OFF \
-		"cockpit" "Install Cockpit" ON \		
+		"cockpit" "Install Cockpit" ON \
  		"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)
 else
Updated by Peter Scargill

File script.sh Modified

  • Ignore whitespace
  • Hide word diff
 ##
 ## We cannot answer questions on board/operating system combinations we have not tested. See notes below for tested combos and dates.
 ## 
+## 23/05/2020 - added cockpit as option in RPI
 ## 16/05/2020 - note at this time the "micro" editor still has cut and paste issues - consider grabbing the latest nightly build and overwriting the /home/pi/micro file
 ##  Example only:
 ##   wget  https://github.com/zyedidia/micro/releases/download/nightly/micro-2.0.4-dev.19-linux-arm.tar.gz
 
 if [[ $OPSYS == *"RASPBIAN"* ]];then
     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 \
+        "\n   Make your selections (SPACE) as required then TAB to OK/Cancel" 29 73 20 \
         "quiet" "Quiet(er) install - untick for lots of info " ON \
         "prereq" "Install general pre-requisites " ON \
         "mosquitto" "Install Mosquitto" ON \
         "rpiclone" "Install RPI-Clone" ON \
         "log2ram" "Install Log2RAM default 40 Meg" OFF \
 		"grafana" "Install Grafana and InfluxDB" OFF \
+		"cockpit" "Install Cockpit" ON \		
  		"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)
 else
     echo "exit 0" | sudo tee -a /etc/rc.local > /dev/null
 fi
 
+if [[ $MYMENU == *"cockpit"* ]]; then
+    printstatus "Adding Cockpit"
+	sudo apt-get update
+	sudo apt install $AQUIET -y --fix-missing cockpit 2>&1 | tee -a $LOGFILE
+	sudo systemctl enable cockpit.socket	
+fi
+
 if [[ $MYMENU == *"wolfram"* ]]; then
     printstatus "Removing Wolfram"
     sudo apt-get $AQUIET -y purge wolfram-engine 2>&1 | tee -a $LOGFILE
Updated by Peter Scargill

File script.sh Modified

  • Ignore whitespace
  • Hide word diff
 ##
 ## We cannot answer questions on board/operating system combinations we have not tested. See notes below for tested combos and dates.
 ## 
+## 16/05/2020 - note at this time the "micro" editor still has cut and paste issues - consider grabbing the latest nightly build and overwriting the /home/pi/micro file
+##  Example only:
+##   wget  https://github.com/zyedidia/micro/releases/download/nightly/micro-2.0.4-dev.19-linux-arm.tar.gz
+##   tar -zxvf micro-2.0.4-dev.19-linux-arm.tar.gz
+##   copy the micro file from the new micro... folder to /home/pi then delete the tar.gz file and the new micro... folder
+##
+## 16/05/2020 added Nginx as an alternative to Apache as a webserver, ONLY tested on Raspbian and Debian BUSTER!
 ## 14/05/2020 added in the MICRO editor (not the nightly),
 ## 	removed ha-bridge as it no longer works and there are other ways to control Alexa today
 ## 11/05/2020 changed reference to http://tech.scargill.net to the https version, 
 
 if [[ $OPSYS == *"RASPBIAN"* ]];then
     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" 27 73 18 \
+        "\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 \
+        "apache" "Install Apache/PHP/SQLITE + PHPLITEADMIN " OFF \
+        "nginx" "Install Nginx/PHP/SQLITE + PHPLITEADMIN " ON \
         "nodenew" "Install NodeJS and NodeRed (Raspberry Pi)" ON \
         "webmin" "Install Webmin" OFF \
         "java" "Update Java" OFF \
         "office" "Remove LibreOffice on PI to save space" OFF 3>&1 1>&2 2>&3)
 else
     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" 28 73 20 \
+        "\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 \
         "apache" "Install Apache/PHP/SQLITE + PHPLITEADMIN" ON \
+        "nginx" "Install Nginx/PHP/SQLITE + PHPLITEADMIN " OFF \
         "nodenew" "Install NodeJS and NodeRed (NEW)" ON \
         "nodejs" "Install NodeJS" OFF \
         "nodered" "Install Node-Red" OFF \
 # Changed the order of installation of Apache etc to solve issues with ARMBIAN
 #
 
-if [[ $MYMENU == *"apache"* ]]; then
-    printstatus "Installing Apache/PHP and Sqlite"
+if [[ $MYMENU == *"apache"* ]] || [[ $MYMENU == *"nginx"* ]]; then
     cd
     sudo groupadd -f -g33 www-data
-    
-    if [[ $OPSYS != *"UBUNTU"* ]]; then
-		if [[ $OPSYS == *"BIAN"* ]] && [[ $DISTRO == *"10"* ]]; then
-			sudo apt-get $AQUIET -y install apache2 libapache2-mod-php7.3 sqlite3 php-sqlite3 php-xml php-mbstring 2>&1 | tee -a $LOGFILE
-		fi
-		if [[ $OPSYS == *"BIAN"* ]] && [[ $DISTRO == *"9."* ]]; then
+    if [[ $MYMENU == *"apache"* ]]; then
+	    printstatus "Installing Apache/PHP and Sqlite"
+		if [[ $OPSYS != *"UBUNTU"* ]]; then
+			if [[ $OPSYS == *"BIAN"* ]] && [[ $DISTRO == *"10"* ]]; then
+				sudo apt-get $AQUIET -y install apache2 libapache2-mod-php7.3 sqlite3 php-sqlite3 php-xml php-mbstring 2>&1 | tee -a $LOGFILE
+			fi
+			if [[ $OPSYS == *"BIAN"* ]] && [[ $DISTRO == *"9."* ]]; then
+				sudo apt-get $AQUIET -y install apache2 libapache2-mod-php7.0 sqlite3 php-sqlite3 php-xml php-mbstring 2>&1 | tee -a $LOGFILE
+			fi
+			if [[ $OPSYS == *"BIAN"* ]] && [[ $DISTRO == *"8"* ]]; then
+				sudo apt-get $AQUIET -y install apache2 libapache2-mod-php5 sqlite3 php5-sqlite 2>&1 | tee -a $LOGFILE
+			fi
+			[ $? -eq 0 ] && webserver=1 # apache installed
+		else
 			sudo apt-get $AQUIET -y install apache2 libapache2-mod-php7.0 sqlite3 php-sqlite3 php-xml php-mbstring 2>&1 | tee -a $LOGFILE
+			[ $? -eq 0 ] && webserver=1 # apache installed
 		fi
-		if [[ $OPSYS == *"BIAN"* ]] && [[ $DISTRO == *"8"* ]]; then
-			sudo apt-get $AQUIET -y install apache2 libapache2-mod-php5 sqlite3 php5-sqlite 2>&1 | tee -a $LOGFILE
+	fi
+	if [[ $MYMENU == *"nginx"* ]]; then
+	    printstatus "Installing NGINX/PHP and Sqlite"
+		if [[ $OPSYS == *"BIAN"* ]] && [[ $DISTRO == *"10"* ]]; then
+			sudo apt-get $AQUIET -y remove --purge *apache* *php* 2>&1 | tee -a $LOGFILE
+			sudo apt-get $AQUIET -y autoremove 2>&1 | tee -a $LOGFILE
+			sudo apt-get $AQUIET -y install nginx sqlite3 php php7.3-{common,cli,fpm,json,zip,gd,mbstring,curl,xml,bcmath,sqlite3} php-pear 2>&1 | tee -a $LOGFILE
+			[ $? -eq 0 ] && webserver=1 # nginx installed
+			sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak
+			sudo sed -i -e 's/index index.html/index index.php index.html/g' /etc/nginx/sites-enabled/default
+			sudo sed -i -e 's/#location ~ \\.php$ {/location ~ \\.php$ {/g' /etc/nginx/sites-enabled/default
+			sudo sed -i -e 's/#.*include snippets\/fastcgi/        include snippets\/fastcgi/g' /etc/nginx/sites-enabled/default
+			sudo sed -i -e 's/#.*fastcgi_pass unix/        fastcgi_pass unix/g' /etc/nginx/sites-enabled/default
+			sudo sed -i -e '63s/#}/}/' /etc/nginx/sites-enabled/default
+			#sudo nginx -t
+			#sudo systemctl restart nginx php7.3-fpm
 		fi
-        [ $? -eq 0 ] && apache=1 # apache installed
-    else
-        sudo apt-get $AQUIET -y install apache2 libapache2-mod-php7.0 sqlite3 php-sqlite3 php-xml php-mbstring 2>&1 | tee -a $LOGFILE
-        [ $? -eq 0 ] && apache=1 # apache installed
-    fi
-    # if apache installed and /var/www/html exists, go on...
-    if [ $apache -eq 1 ] && [ -d /var/www/html ]; then
+	fi
+    # if apache OR nginx installed and /var/www/html exists, go on...
+    if [ $webserver -eq 1 ] && [ -d /var/www/html ]; then
         cd /var/www/html
         sudo mkdir phpliteadmin
         cd phpliteadmin
         chmod 666 /home/pi/dbs/iot.db
         cd
     else
-        printl "${IRed}!!!! Apache+PHP+SQLITE+PHPLITEADMIN NOT INSTALLED! ${IWhite}\r\n"
+        printl "${IRed}!!!! Webserver+PHP+SQLITE+PHPLITEADMIN NOT INSTALLED! ${IWhite}\r\n"
     fi
 fi
 
Updated by Peter Scargill

File script.sh Modified

  • Ignore whitespace
  • Hide word diff
 ##
-##  "The Script" version 5:30pm 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 to use official NR install script on RPi - also fixes to accomodate changed Grafana Repository. 
-##  NetTools added, Glances and Bottle commented out due to issues with their scripting.
-##  Also got rid of NPM warnings
-##
-##  To use my own exact setup you will also need: 
-##  sudo python -m pip install --upgrade pip setuptools wheel
-##  sudo pip install Adafruit-SSD1306
-##  my /home/pi/fonts directory (ProggyTiny.ttf) - and sample programs /home/pi/stats.py and 
-##  stats32.py - this lot for people who want to run ssd1306 diaplays (32 or 64 px high) in Python rather than install i2c support in Node-Red
+## "The Script" is the product of years of work by me (Peter scargill) and others, in particular Antonio Fragola (Mr Shark)
+## Supports Raspberry Pi with Buster full and lite (not tested NOOBS) - also other boards and op systems  see below
 ##
-##  "The Script" is the product of years of work and includes (if you select them):
-##  (Raspberry Pi inc Buster - also tested on Raspbian Stretch Lite - https://downloads.raspberrypi.org/raspbian_lite_latest 
-##  and the full version works just as well)
-##  See also: BigTimer, ESP-GO and other included Node-Red nodes of mine
+## Includes my own Node-Red nodes such as BigTimer.
 ##
-##  Many thanks to Antonio (Mr Shark) for his help.
+## To use my own exact setup you will also need: 
+##  	sudo python -m pip install --upgrade pip setuptools wheel
+##  	sudo pip install Adafruit-SSD1306
+##  	my /home/pi/fonts directory (ProggyTiny.ttf) - and sample programs /home/pi/stats.py and 
+##  	stats32.py - this lot for people who want to run ssd1306 displays (32 or 64 px high) 
+## 		in Python rather than installing i2c support in Node-Red
 ##
-##  Mosquitto (port 1883) with web sockets (Port 9001)
-##  SQLITE ( xxx.xxx.xxx.xxx/phpliteadmin),
-##  Node-Red (xxx.xxx.xxx:1880)
-##  Node-Red-Dashboard (xxx.xxx.xxx.xxx:1880/ui)
-##  Webmin (xxx.xxx.xxx:10000)
-##  Apache (xxx.xxx.xxx)
-##  mpg123
-##  and Grafana (xxx.xxx.xxx:3000)
-##  also web-page-based software like mc, micro and phpsysinfo.
-##  Grafana defaults to password "password" and offers to let you change it.
+## Includes:
+##  	Mosquitto (port 1883) with web sockets (Port 9001)
+##  	SQLITE ( xxx.xxx.xxx.xxx/phpliteadmin),
+##  	Node-Red (xxx.xxx.xxx:1880)
+##  	Node-Red-Dashboard (xxx.xxx.xxx.xxx:1880/ui)
+##  	Webmin (xxx.xxx.xxx:10000)
+##  	Apache (xxx.xxx.xxx) (recommend replacing using nginx)
+##  	mpg123
+##  	Grafana (xxx.xxx.xxx:3000) - defaults to password "password" and offers to let you change it.
+## 		Web-page-based software like mc, micro and phpsysinfo.	
 ##
 ## IMPORTANT:-
-## 1. Run initially ONLY as ROOT on a non-Raspberry Pi machine (or PI user on Raspberry Pi). If ROOT, PI user will be checked/created for you as the main
+## 1. Run initially ONLY as PI on Raspberry Pi (or ROOT on other hardware). If ROOT, PI user will be checked/created for you as the main
 ##    script must be run as pi.
-##    User PI must be in the SUDO group. Other groups are added if needed by the script.
+##    User PI must be in the SUDO group (automatic on Raspberry Pi). Other groups are added if needed by the script.
 ## 2. When selecting GPIO for non-Raspberry Pi devices note - specific support for ODROID C2 only
-## 3. This script could take 3+ hours on a slow Raspberry Pi Zero Wifi.... steer away from midnight to avoid any updates
-##    such as dietpi upgrades etc. //recommend NOT using this on Pi Zero as it will be VERY slow.
+## 3. Steer away from midnight to avoid any updates such as dietpi upgrades etc.
+##    Recommend NOT using this on Pi Zero as it will be VERY slow.
 ## 4. For non-Raspberry Pi systems, when asked by Armbian to make a new user - don't bother - the script will do it.
-## 5. For Node-Red on Pi Zero,  if the serial port won't connect - look at serial port permissions in /dev/
-## 6. Do not access this script as SUDO.
+## 5. Do not access this script as SUDO.
 ##
 ## INSTALLATION:-
-## The easiest way to get the script on your machine is:
-## wget --no-check-certificate  https://bitbucket.org/api/2.0/snippets/scargill/kAR5qG/master/files/script.sh
-## as described here: https://tech.scargill.net/the-script
+## 	The easiest way to get the script on your machine is:
+## 	wget --no-check-certificate  https://bitbucket.org/api/2.0/snippets/scargill/kAR5qG/master/files/script.sh
+## 	as described here: https://tech.scargill.net/the-script
 ##
 ## For Log2RAM customising see this - https://github.com/azlux/log2ram
 ##
 ## See https://tech.scargill.net/orange-pi-pc-battle-of-the-pis/
 ##
-## We cannot answer questions on board/operating system combinations we have not tested. See notes below for tested combos.
+## We cannot answer questions on board/operating system combinations we have not tested. See notes below for tested combos and dates.
 ## 
-## 25/10/2019 I installed all defaults in the script and in addition non-default Grafana onto an ACEPC T9 on which I'd installed the latest Debian Buster
-##            Note that Buster on a non-Pi machine may not have SUDO installed by default. To become a super-user to install it if you can't get to root, "su -".
+## 14/05/2020 added in the MICRO editor (not the nightly),
+## 	removed ha-bridge as it no longer works and there are other ways to control Alexa today
+## 11/05/2020 changed reference to http://tech.scargill.net to the https version, 
+## 	improved remote root access and fixed/improved basic web page, removed DarkSky node
+## 19/12/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 to use official NR install script on RPi - also fixes to accomodate changed Grafana Repository. 
+##  NetTools added, Glances and Bottle commented out due to issues with their scripting.
+##  Also got rid of NPM warnings
+## 25/10/2019 Installed all defaults in the script and in addition non-default Grafana onto an ACEPC T9 on which I'd installed the latest Debian Buster
+## 	Note that Buster on a non-Pi machine may not have SUDO installed by default. To become a super-user to install it if you can't get to root, "su -".
 ## 01/07/2019 used 3-liner as in the blog to upgrade an RPI which had been set up initially using the script in Stretch - to Buster.
 ## 17/02/2019 Added pure-ftp
 ## 07/02/2019 Separated NR into official NR install script, added tcpdump - not added fing but worth doing?
 ##            FriendlyArm's WiringPi i2c is currently bust)
 ## 18/08/2017 Modified to handle latest Raspbian Stretch - tested on RPI3
 ## 10/08/2017 Added "nrlog" utility for viewing and "tailing" - i.e. monitoring node-red logs in colour in
-##            a terminal
+## 	a terminal
 ## 10/08/2017 Tested RPI3 - turns out the new GPIO nodes work perfectly on that - as does i2c
-##  		  - commenting out the RPI contrib GPIO as it needs ROOT permissions!!!!!
-## 			  see https://tech.scargill.net/the-real-raspberry-pi/
+## 	- commenting out the RPI contrib GPIO as it needs ROOT permissions!!!!!
+## 	see https://tech.scargill.net/the-real-raspberry-pi/
 ## 29/07/2017 Added rule to help node-red-contrib-opi-gpio utility with various boards using GPIO. See docs
-## 			  for that node - very promising - tried various nano boards with success
+## 	for that node - very promising - tried various nano boards with success
 ## 24/07/2017 Tested on the new NanoPi Neo Plus2 - worked a treat - I2c running - lovely
 ## 24/07/2017 Tested on a Raspberry Pi 2 using current Jessie
 ## 24/07/2017 Tested NanoPi Neo Air using Ubuntu Core Xenial 4.11.2
 ## 04/07/2017 OrangePi Plus 2 - thanks to blog reader RoyG for that
 ## 26/12/2016 - complete re-hash for new menus
 ## 02/12/2016 Tested Roseapple Pi using Armbian - for Node-Red serial, had to
-## 			  enable permissions for the serial - everything worked first time
+## 	enable permissions for the serial - everything worked first time
 ## 16/05/2016  Tested on NanoPi M1 - (got 3 UARTS out of the M1)
 
 ## 22/06/2016 tested on NanoPi NEO using Armbian Jessie Server
 ## 28/12/2016 tested in DietPi and Xenial virtual machines
-## 			  http://www.armbian.com/donate/?f=Armbian_5.20_Nanopineo_Debian_jessie_3.4.112.7z
+## 	http://www.armbian.com/donate/?f=Armbian_5.20_Nanopineo_Debian_jessie_3.4.112.7z
 ##
 ## NOTE:- removed node-red-contrib-admin from Node-red setup as you can now do installs in the palette manager 
 ## within the editor
 ## you could run the file as ./script.sh
 ##
 ##
-## Note- on the Odroid C2, everything installed except Webmin. After reboot this is what I did to get it running..
+## Note:- on the Odroid C2, everything installed except Webmin. After reboot this is what I did to get it running..
 ##    wget http://prdownloads.sourceforge.net/webadmin/webmin_1.850_all.deb
 ##    sudo dpkg --install webmin_1.850_all.deb
 ##    That complained about missing bits so I used...
 ##    That installed the lot - working - something to do with it being 64 bits - but it works -
 ##    pi or root user and password and https://whatever:10000
 ##
-## Thanks for contributions from Antonio Fragola, Aidan Ruff and others. Thank you.
-##
 ## Node-Red security added as standard - using the ADMIN login. MQTT also has same ADMIN login.
 ##
-## ROUTINES
-## Here at the beginning, a load of useful routines - see further down
 
 # Get time as a UNIX timestamp (seconds elapsed since Jan 1, 1970 0:00 UTC)
 startTime="$(date +%s)"
     fi
 fi
 
-# user pi existance/creation
+# user pi existence/creation for non-Raspberry Pi hardware
 echo -e USER: $USER >> $LOGFILE
 if [[ $USER != "pi" ]]; then
     if [[ $USER == "root" ]]; then
         "passwords" "Update ROOT and PI user passwords" 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)
 else
     MYMENU=$(whiptail --title "Peter Scargill's 'The Script' Main Non-Pi Menu" --checklist \
 
 fi
 
-printstatus  "COMPLETE - PLEASE REBOOT NOW THEN TEST"
+printstatus  "COMPLETE - REBOOT NOW"
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.