Advertisement
Guest User

Basic startup script for a cloned raspi

a guest
Aug 12th, 2014
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.56 KB | None | 0 0
  1. # ~/.profile: executed by the command interpreter for login shells.
  2. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
  3. # exists.
  4. # see /usr/share/doc/bash/examples/startup-files for examples.
  5. # the files are located in the bash-doc package.
  6.  
  7. # the default umask is set in /etc/profile; for setting the umask
  8. # for ssh logins, install and configure the libpam-umask package.
  9. #umask 022
  10.  
  11. # if running bash
  12. if [ -n "$BASH_VERSION" ]; then
  13.     # include .bashrc if it exists
  14.     if [ -f "$HOME/.bashrc" ]; then
  15.         . "$HOME/.bashrc"
  16.     fi
  17. fi
  18.  
  19. rebootFlg="reboot.flg"
  20. expandFlg="expand.flg"
  21.  
  22. # set PATH so it includes user's private bin if it exists
  23. if [ -d "$HOME/bin" ] ; then
  24.     PATH="$HOME/bin:$PATH"
  25. fi
  26.  
  27. # Check ram dedicated to the GPU
  28. if ! grep -q "gpu_mem=128" "/boot/config.txt"; then
  29.     echo "Changing GPU ram"
  30.     sed '/gpu_mem/d' /boot/config.txt | sudo tee /boot/config.txt > /dev/null
  31.     echo "gpu_mem=128" | sudo tee -a /boot/config.txt > /dev/null
  32.     touch "$rebootFlg"
  33. fi
  34.  
  35. # Timezone
  36. if ! cmp --silent /usr/share/zoneinfo/Europe/Lisbon /etc/localtime; then
  37.   sudo cp /usr/share/zoneinfo/Europe/Lisbon /etc/localtime
  38.   echo Changing timezone
  39.   touch "$rebootFlg"
  40. fi
  41.  
  42. # if the flag is present, expand the file system
  43. # resizefs.sh extracted from raspi-config
  44. if [ -f "$expandFlg" ]; then
  45.     echo "Expanding card"
  46.     chmod +x ~/Desktop/raspi/resizefs.sh
  47.     sudo ~/Desktop/raspi/resizefs.sh
  48.     touch "$rebootFlg"
  49.     rm "$expandFlg"
  50. fi
  51.  
  52. # Check serial number
  53. PISERIAL="PI-"`cat /proc/cpuinfo | grep Serial |awk '{gsub ("^0*", "", $3); print $3}'`
  54. if grep -q $PISERIAL "/etc/hostname"; then
  55.     echo "Host:" $PISERIAL
  56. else
  57.     echo "Changing host"
  58.     echo $PISERIAL | sudo tee /etc/hostname > /dev/null
  59.     sed '/127.0.1.1/d' /etc/hosts | sudo tee /etc/hosts > /dev/null
  60.     echo 127.0.1.1 $PISERIAL | sudo tee -a /etc/hosts > /dev/null
  61.     touch "$rebootFlg"
  62. fi
  63.  
  64. # restarts system if required
  65. if [ -f "$rebootFlg" ]; then
  66.     rm "$rebootFlg"
  67.     sudo reboot
  68. fi
  69.  
  70. # Check if session is local or remote
  71. if [[ $(who am i) =~ \([-a-zA-Z0-9\.]+\)$ ]] ; then
  72.     echo Conected by SSH;
  73.     sudo python ~/Desktop/raspi/cfgmenu.py
  74. else
  75.     echo Starting signage system
  76.     echo Press any key to change settings
  77.     if read -n1 -t5 -r -s x; then
  78.        sudo python ~/Desktop/raspi/cfgmenu.py
  79.        sudo reboot
  80.     else
  81.        echo Checking for updates
  82.        cd ~/Desktop/raspi/
  83.        # the update script will start the presentation or restart on completion
  84.        python ./update.py 2>>log.txt
  85.     fi
  86. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement