Skip to content

Commit

Permalink
Merge pull request #16 from jfbibeau/small-setup-fixes
Browse files Browse the repository at this point in the history
Small improvements to setup.sh to fix paths
  • Loading branch information
brycesub authored Sep 2, 2017
2 parents d50ead0 + 21311c2 commit f9face0
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
SCRIPT=$(readlink -f "$0")
BASEDIR=$(dirname "$SCRIPT")

if [[ $(whoami) -ne 'root' ]]; then
echo "Must run as root!"
Expand All @@ -8,7 +10,7 @@ fi
apt-get -y install rpi-update git build-essential python-dev python-smbus python-pip logrotate

echo "Installing logrotate config..."
cp silvia-pi-logrotate /etc/logrotate.d
cp $BASEDIR/silvia-pi-logrotate /etc/logrotate.d

echo "Installing Adafruit GPIO library..."
cd ~
Expand All @@ -28,12 +30,16 @@ git clone https://github.com/ivmech/ivPID.git
cp ~/ivPID/PID.py ~/silvia-pi/

echo "Installing remaining python libraries..."
pip install --upgrade -r requirements.txt

echo "Adding entry to /etc/rc.local"
cp /etc/rc.local /etc/rc.local.bak
cat /etc/rc.local | sed 's|^exit 0$|/root/silvia-pi/silvia-pi.py > /root/silvia-pi/silvia-pi.log 2>\&1 \&\n\nexit 0|g' > /etc/rc.local.new
mv /etc/rc.local.new /etc/rc.local
chmod 755 /etc/rc.local
pip install --upgrade -r $BASEDIR/requirements.txt

if ! grep silvia-pi.py /etc/rc.local; then
echo "Adding entry to /etc/rc.local"
cp /etc/rc.local /etc/rc.local.bak
cat /etc/rc.local | sed 's|^exit 0$|/root/silvia-pi/silvia-pi.py > /root/silvia-pi/silvia-pi.log 2>\&1 \&\n\nexit 0|g' > /etc/rc.local.new
mv /etc/rc.local.new /etc/rc.local
chmod 755 /etc/rc.local
else
echo "Skipping /etc/rc.local modification since entry already found"
fi

echo "Installation complete. Please reboot."

0 comments on commit f9face0

Please sign in to comment.