Advertisement
tom_enos

set_lightshowpi_env.sh

Nov 8th, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.98 KB | None | 0 0
  1. #!/bin/bash
  2. # Setup environment variables
  3. PATH=$PATH
  4. export PATH
  5. INSTALL_DIR="$( cd "$(dirname "$0")" ; pwd -P )"
  6. ENV_VARIABLE="SYNCHRONIZED_LIGHTS_HOME=${INSTALL_DIR}"
  7. exists=`grep -r "$ENV_VARIABLE" /etc/profile*`
  8.  
  9. if [ -z "$exists" ]; then
  10.    echo "# Lightshow Pi Home" > /etc/profile.d/lightshowpi.sh
  11.     echo "$ENV_VARIABLE" >> /etc/profile.d/lightshowpi.sh
  12.     echo "export SYNCHRONIZED_LIGHTS_HOME" >> /etc/profile.d/lightshowpi.sh
  13.     echo "" >> /etc/profile.d/lightshowpi.sh
  14.     echo "# Add Lightshow Pi bin directory to path" >> /etc/profile.d/lightshowpi.sh
  15.     echo "PATH=\$PATH:${INSTALL_DIR}/bin" >> /etc/profile.d/lightshowpi.sh
  16.     echo "export PATH" >> /etc/profile.d/lightshowpi.sh
  17.  
  18.     # Force set this environment variable in this shell (as above doesn't take until reboot)
  19.     export $ENV_VARIABLE
  20. fi
  21.  
  22. KEEP_EN="Defaults   env_keep="SYNCHRONIZED_LIGHTS_HOME""
  23. exists=`grep "$KEEP_EN" /etc/sudoers`
  24.  
  25. if [ -z "$exists" ]; then
  26.     echo "$KEEP_EN" >> /etc/sudoers
  27. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement