Guest User

Untitled

a guest
Dec 11th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.08 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. getUserName (){
  4. read -p "Enter username : " username
  5. if [ "$username" == "" ]; then
  6. echo "Username must not be blank!"
  7. getUserName
  8. fi
  9. }
  10.  
  11. getUserPass (){
  12. read -s -p "Enter password : " password
  13. echo ""
  14. read -s -p "Enter password Again: " repassword
  15. if [ "$password" == "$repassword" ]; then
  16. if [ "$password" == "" ]; then
  17. echo "Password must not be blank!"
  18. getUserPass
  19. fi
  20. echo "Password accepted"
  21. else
  22. echo "Password does not match!"
  23. getUserPass
  24. fi
  25. }
  26.  
  27. #set up user account
  28. getUserName
  29.  
  30. egrep "^$username" /etc/passwd >/dev/null
  31. if [ $? -eq 0 ]; then
  32. read -p "$username exists! Should I configure Ubuntu for this user? (Some configuration files will be altered) [y/n]" reconfig
  33. if [ "$reconfig" != "y" ]; then
  34. echo "Goodbye!"
  35. exit 0
  36. fi
  37. else
  38. getUserPass
  39. pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
  40. useradd -G users,audio,sudo,video,admin -m -s /bin/bash -p $pass $username
  41. echo "$username ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
  42. [ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
  43. fi
  44.  
  45. #find out what we should do
  46. read -p "Choose your window manager LXDE or XFCE4? [lxde/xfce4]" wman
  47. echo ""
  48. echo "Install Florence Virtual Keyboard or Onboard?"
  49. read -p "NOTE: Florence will remap your keyboard so webOS and Bluetooth keybords will not function in Ubuntu![f/o]" keyboard
  50. echo ""
  51. read -p "Install Easystroke? [y/n]" easystroke
  52. echo ""
  53. read -p "Automout USB partition(/media/internal)? [y/n]" usbpart
  54. echo ""
  55. read -p "Install Libre Office? [y/n]" office
  56.  
  57. #ensure a good variable in $wman
  58. if [ "$wman" != "xfce4" ]; then
  59. $wman="lxde"
  60. fi
  61.  
  62. #install a bunch of stuff
  63. echo "Installing window manager, lxterminal, chromium-browser, Leafpad, Synaptic, wmctrl, x11-xkb-utils, libgtkstylus, Lightspark, Gnash, Gamix, SSH, xtightvncviewer, rdesktop, evince, and xournal"
  64. apt-get update
  65. apt-get -y install $wman lxterminal chromium-browser leafpad synaptic wmctrl x11-xkb-utils libgtkstylus browser-plugin-lightspark browser-plugin-gnash gamix ssh xtightvncviewer rdesktop evince xournal < /dev/null
  66.  
  67. #install easystroke and do basic configurations
  68. if [ "$easystroke" == "y" ]; then
  69. echo "Installing Easystroke..."
  70. apt-get -y install easystroke
  71.  
  72. echo "Adding basic easystroke gestures..."
  73. mkdir -p /home/$username/.easystroke/
  74. mkdir -p /home/$username/.config/autostart/
  75. cp preferences-0.4.1 /home/$username/.easystroke/preferences-0.4.1
  76. cp easystroke.desktop /home/$username/.config/autostart/easystroke.desktop
  77. if [ "$keyboard" == "f" ]; then
  78. cp actions-0.4.1.florence /home/$username/.easystroke/actions-0.4.1
  79. else
  80. cp actions-0.4.1.onboard /home/$username/.easystroke/actions-0.4.1
  81. fi
  82. fi
  83.  
  84. #setup internal drive automounting
  85. if [ "$usbpart" == "y" ]; then
  86. echo "Configuring /media/internal..."
  87. mkdir -p /media/internal
  88.  
  89. egrep "/dev/mapper/store-media" /etc/fstab >/dev/null
  90. if [ $? -eq 0 ]; then
  91. echo "USB partition already listed in fstab..."
  92. else
  93. echo "/dev/mapper/store-media /media/internal vfat rw,realtime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0" >> /etc/fstab
  94. mount -a
  95. #ensure the usb partition mounts if desired
  96. echo "umount /media/internal" >> /root/.bashrc
  97. echo "mount /media/internal" >> /root/.bashrc
  98. fi
  99.  
  100. else
  101. echo "Skippig USB partition..."
  102. fi
  103.  
  104. #install libre office
  105. if [ "$office" == "y" ]; then
  106. echo "Installing Libre Office..."
  107. apt-get -y install libreoffice < /dev/null
  108. else
  109. echo "Skipping Libre Office..."
  110. fi
  111.  
  112. #Install virtual keyboard
  113. if [ "$keyboard" == "f" ]; then
  114. #set up florence keyboard
  115. apt-get -y install florence < /dev/null
  116. echo "Remapping keyboard..."
  117. egrep "setxkbmap us" /usr/bin/start$wman >/dev/null
  118. if [ $? -eq 0 ]; then
  119. echo "keyboard layout already set in /usr/bin/start$wman ..."
  120. else
  121. sed -i '4i #Remap keyboard. Comment out to allow webOS keyboard to function.' "/usr/bin/start$wman"
  122. sed -i '5i setxkbmap us' "/usr/bin/start$wman"
  123. fi
  124.  
  125. #configure autostart for florence
  126. echo "Configuring Florence to autostart"
  127. mkdir -p /home/$username/.config/autostart/
  128. cp florence.desktop /home/$username/.config/autostart/florence.desktop
  129.  
  130. else
  131. #setup onboard virtual keyboard
  132. sed -i 's/Remap keyboard. Comment out to allow webOS keyboard to function.//g' "/usr/bin/start$wman"
  133. sed -i 's/setxkbmap us//g' "/usr/bin/start$wman"
  134. rm /home/$username/.config/autostart/florence.desktop
  135. apt-get -y install onboard < /dev/null
  136. cp obwrap.sh /usr/local/bin/obwrap.sh
  137. cp Default.onboard /usr/share/onboard/layouts/Default.onboard
  138. chmod a+x /usr/local/bin/obwrap.sh
  139. fi
  140.  
  141. #setup gtk rightclick
  142. echo "Adding long tap for right click..."
  143. egrep "libgtkstylus.so" /usr/bin/start$wman >/dev/null
  144. if [ $? -eq 0 ]; then
  145. echo "libgtkstylus already referenced in /usr/bin/start$wman ..."
  146. else
  147. sed -i '2i #load right click driver' "/usr/bin/start$wman"
  148. sed -i '3i export GTK_MODULES=libgtkstylus.so' "/usr/bin/start$wman"
  149. fi
  150.  
  151. #configure autostarting window manager
  152. echo "Setting up autostart for dbus and window manager..."
  153. egrep "su - $username" /root/.bashrc >/dev/null
  154. if [ $? -eq 0 ]; then
  155. echo "autostart already configured ..."
  156. else
  157. echo "su - $username -c \"dbus-launch start$wman\" 2> /home/$username/.start$wman.err" >> /root/.bashrc
  158. cp moveStartupTerm.desktop /home/$username/.config/autostart/moveStartupTerm.desktop
  159. cp moveStartupTerm.sh /usr/local/bin/moveStartupTerm.sh
  160. chown $username /usr/local/bin/moveStartupTerm.sh
  161. chmod a+x /usr/local/bin/moveStartupTerm.sh
  162. fi
  163.  
  164. if [ "$wman" == "xfce4" ]; then
  165. #do xfce configuration
  166. mkdir -p /home/$username/.config/
  167. cp xfce4.tar.gz /home/$username/.config/
  168. cd /home/$username/.config
  169. tar xzfv xfce4.tar.gz
  170. cd -
  171. else
  172. #do some lxde optimization
  173. echo "Configuring LX panel..."
  174. mkdir -p /home/$username/.config/lxpanel/LXDE/panels/
  175. mkdir -p /home/$username/.config/openbox/
  176. cp lxpanel.panel /home/$username/.config/lxpanel/LXDE/panels/panel
  177. cp lxde-rc.xml /home/$username/.config/openbox/lxde-rc.xml
  178. fi
  179.  
  180. #setup first start script
  181. cp firststart.desktop /home/$username/.config/autostart/firststart.desktop
  182. cp firststart.sh /usr/local/bin/firststart.sh
  183. chmod a+x /usr/local/bin/firststart.sh
  184.  
  185. #fix the sudo unresolved host error
  186. hostname > hostnameholder
  187. hostnameholder=`cat hostnameholder`
  188. sed -i "s/ubuntu-natty-chroot/$hostnameholder/g" "/etc/hosts"
  189. rm hostnameholder
  190.  
  191. #Configure Sound
  192. chmod a+rw /dev/snd/*
  193. chmod a+rw /dev/msm*
  194. mkdir -p /home/$username/.gamix
  195. cp gamix.Config /home/$username/.gamix/Config
  196. cp gamix.desktop /usr/share/applications/
  197. cp volume.png /usr/share/applications/
  198. cp asoundrc /home/$username/.asoundrc
  199.  
  200. #configure some gnome app stuff
  201. mkdir -p /home/$username
  202. cp gconf.tar.gz /home/$username/
  203. cd /home/$username
  204. tar xzfv gconf.tar.gz
  205. rm gconf.tar.gz
  206.  
  207. #Change ownership of a bunch of stuff
  208. chown -R $username /home/$username
  209. chown $username /usr/local/bin/firststart.sh
  210.  
  211. #clean up
  212. apt-get -y clean
  213.  
  214. #start window manager
  215. su - $username -c "dbus-launch start$wman" > /home/$username/.windowManager.err
Add Comment
Please, Sign In to add comment