EDIT: You have to remove temporarily, the exit 0
in the comments of /etc/rc.local
otherwise sed -i '/exit 0/i\/etc\/S99rc.installer' /etc/rc.local
will be inserted after each exit 0
. Or change the script accordingly:
http://stackoverflow.com/questions/29256795/how-to-insert-a-line-before-the-first-and-last-matching-pattern-using-sedhttps://stackoverflow.com/questions/29256795/how-to-insert-a-line-before-the-first-and-last-matching-pattern-using-sed
EDIT: You have to remove temporarily, the exit 0
in the comments of /etc/rc.local
otherwise sed -i '/exit 0/i\/etc\/S99rc.installer' /etc/rc.local
will be inserted after each exit 0
. Or change the script accordingly:
http://stackoverflow.com/questions/29256795/how-to-insert-a-line-before-the-first-and-last-matching-pattern-using-sed
EDIT: You have to remove temporarily, the exit 0
in the comments of /etc/rc.local
otherwise sed -i '/exit 0/i\/etc\/S99rc.installer' /etc/rc.local
will be inserted after each exit 0
. Or change the script accordingly:
https://stackoverflow.com/questions/29256795/how-to-insert-a-line-before-the-first-and-last-matching-pattern-using-sed
#RASPI INSTALLATION SCRIPT
set -eu #exit on any error & show bugs
Failure () {
sudo -u pi echo rm /home/pi/installscript.status
exit 1
echo "FAILURE PLEASE CHECK INSTALLSCRIPT"
}
echo "PLEASE DO RASPI-CONFIG BEFORE: set boot to logged in and non desktop mode"
counter=0
while [ -f /home/pi/installscript.status ]; do
counter=$((counter+1))
if [ "$counter" -gt "100" ]
then
Failure
fi
status=$(< /home/pi/installscript.status)
sudo -u pi echo "Current install step: $status"
#=================================== WIFI SETUP && SYSTEM UPGRADE ==========================================
if [ "$status" == "start" ] #wifi setup
then
chmod 755 /etc/S99rc.installer
sed -i '/exit 0/i\/etc\/S99rc.installer' /etc/rc.local
echo "setup autostart installer"
printf 'network={%s\n\tssid="YOUR_SSID"%s\n\tpsk="YOUR_PASSWORD"%s\n}' >> /etc/wpa_supplicant/wpa_supplicant.conf
echo "setup wifi"
apt-get update
apt-get upgrade
'swap' > /home/pi/installscript.status
echo "upgraded system"
#=================================== INCREASE SWAP ==========================================
elif [ "$status" == "swap" ] #increase swap space
then
sed -i.bak 's/^\(CONF_SWAPFILE=\).*/\11000/' /etc/dphys-swapfile
/etc/init.d/dphys-swapfile start
sleep 5
free -m
sudo -u pi echo 'database' > /home/pi/installscript.status
echo "increased swap"
#=================================== RETHINKDB ==========================================
elif [ "$status" == "database" ]
then
apt-get install g++ protobuf-compiler libprotobuf-dev libboost-dev curl m4 wget
cd /home/pi/Downloads
wget https://download.rethinkdb.com/dist/rethinkdb-2.3.0.tgz
tar vxf rethinkdb-2.3.0.tgz
cd rethinkdb-2.3.0
./configure --with-system-malloc --allow-fetch
make ALLOW_WARNINGS=1
make install ALLOW_WARNINGS=1
sudo -u pi echo 'swap2' > /home/pi/installscript.status
echo "installed rethinkdb 2.3.0"
#=================================== DECREASE SWAP ==========================================
elif [ "$status" == "swap2" ] #decrease swap space
then
sed -i.bak 's/^\(CONF_SWAPFILE=\).*/\1100/' /etc/dphys-swapfile
/etc/init.d/dphys-swapfile start
sleep 10
free -m
sudo -u pi echo 'autostart' > /home/pi/installscript.status
echo "decreased swap"
#=================================== APPLY AUTOSTARTS ==========================================
elif [ "$status" == "autostart" ]
then
#database
sed -i '/exit 0/irethinkdb --http-port port 8090' /etc/rc.local
sudo -u pi echo 'delete' > /home/pi/installscript.status
echo "added autostarts"
elif [ "$status" == "delete" ] #clean up when the script was succesful
then
sudo -u pi echo rm /home/pi/installscript.status
sed -i.bak '/bash \/etc\/S99rc.installer/d' /etc/rc.local
echo "installations finished"
exit 0
reboot
else
Failure
fi
done
ls -l /home/pi/installscript.status
echo "nothing to do"
exit 0
EDIT: You have to remove temporarily, the exit 0
in the comments of /etc/rc.local
otherwise sed -i '/exit 0/i\/etc\/S99rc.installer' /etc/rc.local
will be inserted after each exit 0
. Or change the script accordingly:
http://stackoverflow.com/questions/29256795/how-to-insert-a-line-before-the-first-and-last-matching-pattern-using-sed
#RASPI INSTALLATION SCRIPT
set -eu #exit on any error & show bugs
Failure () {
sudo -u pi echo rm /home/pi/installscript.status
exit 1
echo "FAILURE PLEASE CHECK INSTALLSCRIPT"
}
echo "PLEASE DO RASPI-CONFIG BEFORE: set boot to logged in and non desktop mode"
counter=0
while [ -f /home/pi/installscript.status ]; do
counter=$((counter+1))
if [ "$counter" -gt "100" ]
then
Failure
fi
status=$(< /home/pi/installscript.status)
sudo -u pi echo "Current install step: $status"
#=================================== WIFI SETUP && SYSTEM UPGRADE ==========================================
if [ "$status" == "start" ] #wifi setup
then
chmod 755 /etc/S99rc.installer
sed -i '/exit 0/i\/etc\/S99rc.installer' /etc/rc.local
echo "setup autostart installer"
printf 'network={%s\n\tssid="YOUR_SSID"%s\n\tpsk="YOUR_PASSWORD"%s\n}' >> /etc/wpa_supplicant/wpa_supplicant.conf
echo "setup wifi"
apt-get update
apt-get upgrade
'swap' > /home/pi/installscript.status
echo "upgraded system"
#=================================== INCREASE SWAP ==========================================
elif [ "$status" == "swap" ] #increase swap space
then
sed -i.bak 's/^\(CONF_SWAPFILE=\).*/\11000/' /etc/dphys-swapfile
/etc/init.d/dphys-swapfile start
sleep 5
free -m
sudo -u pi echo 'database' > /home/pi/installscript.status
echo "increased swap"
#=================================== RETHINKDB ==========================================
elif [ "$status" == "database" ]
then
apt-get install g++ protobuf-compiler libprotobuf-dev libboost-dev curl m4 wget
cd /home/pi/Downloads
wget https://download.rethinkdb.com/dist/rethinkdb-2.3.0.tgz
tar vxf rethinkdb-2.3.0.tgz
cd rethinkdb-2.3.0
./configure --with-system-malloc --allow-fetch
make ALLOW_WARNINGS=1
make install ALLOW_WARNINGS=1
sudo -u pi echo 'swap2' > /home/pi/installscript.status
echo "installed rethinkdb 2.3.0"
#=================================== DECREASE SWAP ==========================================
elif [ "$status" == "swap2" ] #decrease swap space
then
sed -i.bak 's/^\(CONF_SWAPFILE=\).*/\1100/' /etc/dphys-swapfile
/etc/init.d/dphys-swapfile start
sleep 10
free -m
sudo -u pi echo 'autostart' > /home/pi/installscript.status
echo "decreased swap"
#=================================== APPLY AUTOSTARTS ==========================================
elif [ "$status" == "autostart" ]
then
#database
sed -i '/exit 0/irethinkdb --http-port port 8090' /etc/rc.local
sudo -u pi echo 'delete' > /home/pi/installscript.status
echo "added autostarts"
elif [ "$status" == "delete" ] #clean up when the script was succesful
then
sudo -u pi echo rm /home/pi/installscript.status
sed -i.bak '/bash \/etc\/S99rc.installer/d' /etc/rc.local
echo "installations finished"
exit 0
reboot
else
Failure
fi
done
ls -l /home/pi/installscript.status
echo "nothing to do"
exit 0
#RASPI INSTALLATION SCRIPT
set -eu #exit on any error & show bugs
Failure () {
sudo -u pi echo rm /home/pi/installscript.status
exit 1
echo "FAILURE PLEASE CHECK INSTALLSCRIPT"
}
echo "PLEASE DO RASPI-CONFIG BEFORE: set boot to logged in and non desktop mode"
counter=0
while [ -f /home/pi/installscript.status ]; do
counter=$((counter+1))
if [ "$counter" -gt "100" ]
then
Failure
fi
status=$(< /home/pi/installscript.status)
sudo -u pi echo "Current install step: $status"
#=================================== WIFI SETUP && SYSTEM UPGRADE ==========================================
if [ "$status" == "start" ] #wifi setup
then
chmod 755 /etc/S99rc.installer
sed -i '/exit 0/i\/etc\/S99rc.installer' /etc/rc.local
echo "setup autostart installer"
printf 'network={%s\n\tssid="YOUR_SSID"%s\n\tpsk="YOUR_PASSWORD"%s\n}' >> /etc/wpa_supplicant/wpa_supplicant.conf
echo "setup wifi"
apt-get update
apt-get upgrade
'swap' > /home/pi/installscript.status
echo "upgraded system"
#=================================== INCREASE SWAP ==========================================
elif [ "$status" == "swap" ] #increase swap space
then
sed -i.bak 's/^\(CONF_SWAPFILE=\).*/\11000/' /etc/dphys-swapfile
/etc/init.d/dphys-swapfile start
sleep 5
free -m
sudo -u pi echo 'database' > /home/pi/installscript.status
echo "increased swap"
#=================================== RETHINKDB ==========================================
elif [ "$status" == "database" ]
then
apt-get install g++ protobuf-compiler libprotobuf-dev libboost-dev curl m4 wget
cd /home/pi/Downloads
wget https://download.rethinkdb.com/dist/rethinkdb-2.3.0.tgz
tar vxf rethinkdb-2.3.0.tgz
cd rethinkdb-2.3.0
./configure --with-system-malloc --allow-fetch
make ALLOW_WARNINGS=1
make install ALLOW_WARNINGS=1
sudo -u pi echo 'swap2' > /home/pi/installscript.status
echo "installed rethinkdb 2.3.0"
#=================================== DECREASE SWAP ==========================================
elif [ "$status" == "swap2" ] #decrease swap space
then
sed -i.bak 's/^\(CONF_SWAPFILE=\).*/\1100/' /etc/dphys-swapfile
/etc/init.d/dphys-swapfile start
sleep 10
free -m
sudo -u pi echo 'autostart' > /home/pi/installscript.status
echo "decreased swap"
#=================================== APPLY AUTOSTARTS ==========================================
elif [ "$status" == "autostart" ]
then
#database
sed -i '/exit 0/irethinkdb --http-port 8090' /etc/rc.local
sudo -u pi echo 'delete' > /home/pi/installscript.status
echo "added autostarts"
elif [ "$status" == "delete" ] #clean up when the script was succesful
then
sudo -u pi echo rm /home/pi/installscript.status
sed -i.bak '/bash \/etc\/S99rc.installer/d' /etc/rc.local
echo "installations finished"
exit 0
reboot
else
Failure
fi
done
ls -l /home/pi/installscript.status
echo "nothing to do"
exit 0
EDIT: You have to remove temporarily, the exit 0
in the comments of /etc/rc.local
otherwise sed -i '/exit 0/i\/etc\/S99rc.installer' /etc/rc.local
will be inserted after each exit 0
. Or change the script accordingly:
http://stackoverflow.com/questions/29256795/how-to-insert-a-line-before-the-first-and-last-matching-pattern-using-sed
From my experience. Swap space on a SD Card is considered as not trustworthy and it also slows down the installation process.
disable any boot to desktop in
raspi-config
, this saves valuable memory.disable unnecessary autostart executions
do the most critical installation (for me rethinkdb) first
write an installation script, this makes it easier to start from a bare img if you have to start again. Also it allows you easily to change the order and retry the installation.
save your SD after each crucial step to an img/after the installation
I copy my installation script in here, maybe you can use it, if not the important steps can be extracted from the script. Please let me know if you need some explanation to one of the steps.
You have to set YOUR_SSID and YOUR_PASSWORD to include your Wifi. Copy this script in a new file:
nano /etc/S99rc.installer
and add a file with echo "start">/home/pi/installscript.status
.
I started in the middle with applying this script, so no warranty that this works, maybe some adaption is necessary.
#RASPI INSTALLATION SCRIPT
set -eu #exit on any error & show bugs
Failure () {
sudo -u pi echo rm /home/pi/installscript.status
exit 1
echo "FAILURE PLEASE CHECK INSTALLSCRIPT"
}
echo "PLEASE DO RASPI-CONFIG BEFORE: set boot to logged in and non desktop mode"
counter=0
while [ -f /home/pi/installscript.status ]; do
counter=$((counter+1))
if [ "$counter" -gt "100" ]
then
Failure
fi
status=$(< /home/pi/installscript.status)
sudo -u pi echo "Current install step: $status"
#=================================== WIFI SETUP && SYSTEM UPGRADE ==========================================
if [ "$status" == "start" ] #wifi setup
then
chmod 755 /etc/S99rc.installer
sed -i '/exit 0/i\/etc\/S99rc.installer' /etc/rc.local
echo "setup autostart installer"
printf 'network={%s\n\tssid="YOUR_SSID"%s\n\tpsk="YOUR_PASSWORD"%s\n}' >> /etc/wpa_supplicant/wpa_supplicant.conf
echo "setup wifi"
apt-get update
apt-get upgrade
'swap' > /home/pi/installscript.status
echo "upgraded system"
#=================================== INCREASE SWAP ==========================================
elif [ "$status" == "swap" ] #increase swap space
then
sed -i.bak 's/^\(CONF_SWAPFILE=\).*/\11000/' /etc/dphys-swapfile
/etc/init.d/dphys-swapfile start
sleep 5
free -m
sudo -u pi echo 'database' > /home/pi/installscript.status
echo "increased swap"
#=================================== RETHINKDB ==========================================
elif [ "$status" == "database" ]
then
apt-get install g++ protobuf-compiler libprotobuf-dev libboost-dev curl m4 wget
cd /home/pi/Downloads
wget https://download.rethinkdb.com/dist/rethinkdb-2.3.0.tgz
tar vxf rethinkdb-2.3.0.tgz
cd rethinkdb-2.3.0
./configure --with-system-malloc --allow-fetch
make ALLOW_WARNINGS=1
make install ALLOW_WARNINGS=1
sudo -u pi echo 'swap2' > /home/pi/installscript.status
echo "installed rethinkdb 2.3.0"
#=================================== DECREASE SWAP ==========================================
elif [ "$status" == "swap2" ] #decrease swap space
then
sed -i.bak 's/^\(CONF_SWAPFILE=\).*/\1100/' /etc/dphys-swapfile
/etc/init.d/dphys-swapfile start
sleep 10
free -m
sudo -u pi echo 'autostart' > /home/pi/installscript.status
echo "decreased swap"
#=================================== APPLY AUTOSTARTS ==========================================
elif [ "$status" == "autostart" ]
then
#database
sed -i '/exit 0/irethinkdb --http-port port 8090' /etc/rc.local
sudo -u pi echo 'delete' > /home/pi/installscript.status
echo "added autostarts"
elif [ "$status" == "delete" ] #clean up when the script was succesful
then
sudo -u pi echo rm /home/pi/installscript.status
sed -i.bak '/bash \/etc\/S99rc.installer/d' /etc/rc.local
echo "installations finished"
exit 0
reboot
else
Failure
fi
done
ls -l /home/pi/installscript.status
echo "nothing to do"
exit 0