Advertisement
Guest User

Untitled

a guest
Apr 6th, 2017
1,090
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. #!/bin/bash
  2. ROOT_UID=0
  3. SUCCESS=0
  4. E_USEREXISTS=70
  5.  
  6.  
  7. ######
  8.  
  9. # If this file wont run preform ther commands:
  10. # sudo apt install dos2unix
  11. # sudo dos2unix -f -n RunAsPi.bash ~/Fixed_RunAsPi.bash
  12.  
  13. #######
  14.  
  15.  
  16. # Credentials of the tmux window user
  17. username="default"
  18. password="DankMeme"
  19.  
  20. read -s -p "Enter password for user mathijs : " mathijs_password
  21.  
  22. if [ "$UID" -ne "$ROOT_UID" ]
  23. then
  24. echo "Must be root to run this script."
  25. exit $E_NOTROOT
  26. fi
  27.  
  28. apt update -y && apt upgrade -y && apt install git byobu htop ethstatus mplayer links tmux -y
  29.  
  30. groupadd -g 10000 administrators
  31.  
  32. useradd -p `mkpasswd "$password"` -d /home/"$username" -m -g users -s /bin/bash "$username"
  33. useradd -p `mkpasswd "$mathijs_password"` -d /home/"mathijs" -m -g administrators,users,sudo -s /bin/bash "mathijs"
  34. echo "the account is setup"
  35.  
  36.  
  37.  
  38.  
  39. touch /etc/systemd/system/getty@tty1.service.d/autologin.conf
  40. echo "[Service]" >> /etc/systemd/system/getty@tty1.service.d/autologin.conf
  41. echo "ExecStart=" >> /etc/systemd/system/getty@tty1.service.d/autologin.conf
  42. echo "ExecStart=-/sbin/agetty --autologin $username --noclear %I 38400 linux" >> /etc/systemd/system/getty@tty1.service.d/autologin.conf
  43. chmod +x /etc/systemd/system/getty@tty1.service.d/autologin.conf
  44.  
  45.  
  46. echo 'alias tmux_setup="if [ -z "$TMUX" ]; \' >> /home/$username/.bashrc
  47. echo "then echo 'Not inside TMUX! Aborting...'; else ~/scripts/tmux_setup.bash;fi\"" >> /home/$username/.bashrc
  48.  
  49. mkdir /opt/scripts
  50. echo "#!/bin/bash" >> /opt/scripts/tmux_setup.bash
  51. echo " " >> /opt/scripts/tmux_setup.bash
  52. echo "tmux set -g pane-border-fg green" >> /opt/scripts/tmux_setup.bash
  53. echo "tmux set -g pane-border-bg black" >> /opt/scripts/tmux_setup.bash
  54. echo "tmux set -g pane-active-border-fg red" >> /opt/scripts/tmux_setup.bash
  55. echo "tmux set -g pane-active-border-bg black" >> /opt/scripts/tmux_setup.bash
  56. echo "tmux split-window -h \"bash -c 'while true; do htop;done'\"" >> /opt/scripts/tmux_setup.bash
  57. echo "tmux resize-pane -R 41" >> /opt/scripts/tmux_setup.bash
  58. echo "tmux split-window -v \"bash -c 'while true; do ethstatus -i eth0;done'\"" >> /opt/scripts/tmux_setup.bash
  59. echo "tmux resize-pane -D 10" >> /opt/scripts/tmux_setup.bash
  60. echo "tmux select-pane -L" >> /opt/scripts/tmux_setup.bash
  61. echo "tmux split-window -v \"bash -c 'while true; do echo'Netstat IPv4'; netstat -4; sleep 5; clear; done'\"" >> /opt/scripts/tmux_setup.bash
  62. echo "tmux split-window -v \"bash -c 'while true; do echo'Netstat IPv6'; netstat -6; sleep 5; clear; done'\"" >> /opt/scripts/tmux_setup.bash
  63. echo "tmux select-pane -L" >> /opt/scripts/tmux_setup.bash
  64. echo "tmux select-pane -U" >> /opt/scripts/tmux_setup.bash
  65. echo "reset" >> /opt/scripts/tmux_setup.bash
  66. echo "bash" >> /opt/scripts/tmux_setup.bash
  67.  
  68.  
  69. echo "[ -r /home/$username/.byobu/prompt ] && . /home/$username/.byobu/prompt #byobu-prompt#" >> /home/$username/.bashrc
  70.  
  71. su -c "byobu-enable-prompt" $username
  72.  
  73. echo "byobu new-session -s \"Default_Session\" /opt/scripts/tmux_setup.bash" >> /home/$username/.profile
  74.  
  75.  
  76.  
  77. chown $username:administrators -R /home/$username/
  78. chown mathijs:administrators -R /opt/scripts/
  79. chmod 575 -R /home/$username/
  80. chmod 775 -R /opt/scripts/
  81. chmod 775 /home/$username/.byobu/
  82. chmod 775 -R /home/$username/.byobu/bin/
  83.  
  84.  
  85.  
  86. echo "************************************************************"
  87. echo "DONE"
  88. echo "************************************************************"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement