Skip to content

Commit

Permalink
Merge pull request #182 from CDuffers/logging
Browse files Browse the repository at this point in the history
Enhancement to log init.sh and main.sh install scripts from issue #64
  • Loading branch information
TrystanLea authored Oct 18, 2023
2 parents c09ab24 + 5bc2f38 commit 6c09f8d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/install-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ All these links, link to the `stable` branch.

The installation process is broken out into separate scripts that can be run individually.

**[init.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/init.sh)** Launches the full installation script, first downloading the EmonScripts repository that contains the rest of the installation scripts.
**[init.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/init.sh)** Launches the full installation script, first downloading the EmonScripts repository that contains the rest of the installation scripts. All output sent to screen also stored in the user's home directory `~/init.sh.log`.

**[main.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/main.sh)** Loads the configuration file and runs the individual installation scripts as applicable.
**[main.sh:](https://github.com/openenergymonitor/EmonScripts/blob/stable/install/main.sh)** Loads the configuration file and runs the individual installation scripts as applicable. All output sent to screen also stored in the user's home directory `~/main.sh.log`.

---

Expand Down
2 changes: 2 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ chmod +x init.sh && ./init.sh

The `init` script automatically calls the `main` script. At this point you will be offered the option to configure the installation process.

Output from `init.sh` is displayed on screen and also stored in the user's home directory `~/init.sh.log`. Output from `main.sh` is also displayed on screen and stored in the user's home directory `~/main.sh.log`.

If you are on a RaspberryPi or EmonPi you can usually just proceed.

Be patient, the install process takes some time.
Expand Down
11 changes: 11 additions & 0 deletions install/init.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/bin/bash

# Copy stdout and stderr to a log file in addition to the console
# tee -a used in case script is run multiple times

LOG_FILE=~/$(basename "$0").log
exec > >(tee -a "${LOG_FILE}") 2>&1

echo "Script output also stored in ${LOG_FILE}"
echo -e "Started: $(date)\n"

user=$USER
openenergymonitor_dir=/opt/openenergymonitor
emoncms_dir=/opt/emoncms
Expand All @@ -24,3 +33,5 @@ cd $openenergymonitor_dir/EmonScripts/install
cd

rm init.sh

echo -e "\nScript output also stored in ${LOG_FILE}"
20 changes: 12 additions & 8 deletions install/main.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# --------------------------------------------------------------------------------
# RaspberryPi Strech Build Script
# Emoncms, Emoncms Modules, EmonHub & dependencies
Expand All @@ -13,12 +14,20 @@
# - emonhub installer
# Format as documentation

# Copy stdout and stderr to a log file in addition to the console
# tee -a used in case script is run multiple times

LOG_FILE=~/$(basename "$0").log
exec > >(tee -a "${LOG_FILE}") 2>&1

echo "Script output also stored in ${LOG_FILE}"
echo -e "Started: $(date)\n"

# fix interactive popup that keeps asking for service restart
if [ -f /etc/needrestart/needrestart.conf ]; then
sudo sed -i 's/#$nrconf{restart} = '"'"'i'"'"';/$nrconf{restart} = '"'"'a'"'"';/g' /etc/needrestart/needrestart.conf
fi

#!/bin/bash
if [ ! -f config.ini ]; then
cp emonsd.config.ini config.ini
fi
Expand Down Expand Up @@ -100,13 +109,8 @@ if [ "$emonSD_pi_env" = "1" ]; then
# update checks for image type and only runs with a valid image name file in the boot partition
# Update this value to the latest safe image version - this could be automated to pull from safe list
sudo touch /boot/emonSD-10Nov22
exit 0
# Reboot to complete
sudo reboot
else
$openenergymonitor_dir/EmonScripts/install/non_emonsd.sh;
# sudo touch /boot/emonSD-30Oct18
exit 0
# Reboot to complete
sudo reboot
fi

echo -e "\nScript output also stored in ${LOG_FILE}"

0 comments on commit 6c09f8d

Please sign in to comment.