Advertisement
Guest User

Jakadinho

a guest
Mar 1st, 2009
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 18.84 KB | None | 0 0
  1. #!/bin/bash
  2. # A script to automate installation and configuration of ArchLinux
  3. # Author: Jakadinho
  4. # v0.1.1
  5. # ======================================================================== #
  6. # Run this script as root.
  7.  
  8. user=$UID
  9.  if [ $user != 0 ]
  10.   then
  11.   echo -e "\e[1;31mSorry. Only ROOT user can run this program !\e[0m"
  12.   exit
  13.  fi
  14.  
  15. ################################################################################
  16. # PACKETS== ====================================================================#
  17. ################################################################################
  18.  
  19.  
  20. # Edit in order to change installed packages.
  21. multi="xine-lib xine-ui amarok-engine-xine alsa-lib alsa-oss alsa-utils alsaplayer gstreamer0.10-alsa alsa-plugins mplayer mplayer-plugin amarok-base amarok-engine-xine gstreamer0.10 smplayer-themes smplayer flashplugin f-spot"
  22.  
  23. reco="sakura gedit"
  24.  
  25. inter="firefox deluge skype pidgin checkgmail" #if you remove checkgmail you also have to edit function "finternet" (line 282)
  26.  
  27.  
  28. ################################################################################
  29. # QUESTIONS ====================================================================#
  30. ################################################################################
  31.  
  32.  
  33. # UPDATE ===================================================================#Q
  34. function q_update {
  35. dialog --yesno "Did you recently update system (pacman -Syu) ?" 10 50
  36. case $? in
  37.   1)
  38.     pacman -Syu --noconfirm;;
  39.   255)
  40.     last;;
  41. esac
  42. }
  43.  
  44. # USERNAME =================================================================#Q
  45. function q_user {
  46.     dialog \
  47.     --menu "Select one option:" 12 60 5 \
  48.     1 "Use existing user" \
  49.     2 "Create new user" 2>/tmp/user_ch
  50.          user_choice="`cat /tmp/user_ch`"
  51.          if [[ "$user_choice" == 2 ]]
  52.          then
  53.          q_newuser
  54.          fi
  55.          if [[ "$user_choice" == 1 ]]
  56.          then
  57.          q_username
  58.          fi
  59. }
  60.  
  61. function q_newuser {
  62.    dialog --inputbox "Please enter desired username):   " 15 40 2>/tmp/u_name
  63.          u_name="`cat /tmp/u_name`"
  64.          useradd -m -G users,audio,lp,optical,storage,video,wheel,power -s /bin/bash $u_name
  65.          echo "Set $u_name's password"
  66.          passwd $u_name
  67. }
  68.  
  69. function q_username {
  70.   dialog --inputbox "Please enter your username (openbox config will be written only for this user!!!!): " 15 40 2>/tmp/u_name
  71.            u_name="`cat /tmp/u_name`"
  72. }
  73.  
  74. # ARCHITECTURE =============================================================#Q
  75. function q_architecture {
  76.     dialog \
  77.     --menu "Select witch architecture you use:" 12 60 5 \
  78.      "i686" "1" \
  79.      "x86_64" "2" 2>/tmp/archite
  80.              architecture="`cat /tmp/archite`"
  81. }
  82.  
  83. # YAOURT ===================================================================#Q
  84. function q_yaourt {
  85. dialog --yesno "Do you wish to install and configure Yaourt? This script may depend on it later so it is recomended to install!!!!" 10 50
  86. case $? in
  87.   0)
  88.     fyaourt;;
  89.   255)
  90.     last;;
  91. esac
  92. }
  93.  
  94. # VOLWHEEL =================================================================#Q
  95. function q_volwheel {
  96. dialog --yesno "Volwheel is tray icon that change volume with the mouse wheel or clicks. Do you wish to install and configure it ?" 10 50
  97. case $? in
  98.   0)
  99.     volwheel;;
  100.   255)
  101.     last;;
  102. esac
  103. }
  104.  
  105. # BMPANEL ==================================================================#Q
  106. function q_bmpanel {
  107. dialog --yesno "Bmpanel is a modern, NETWM compliant, bitmap theme-based x11 panel. (Depends on Yaourt) Do you wish to install and configure it ?" 10 50
  108. case $? in
  109.   0)
  110.     bmpanel;;
  111.   255)
  112.     last;;
  113. esac
  114. }
  115.  
  116. # XSCREENSAVER =============================================================#Q
  117. function q_xscreen {
  118. dialog --yesno "Xscreensaver is screen saver and locker for the X Window System. Do you wish to install and configure it ?" 10 50
  119. case $? in
  120.   0)
  121.     xscreen;;
  122.   255)
  123.     last;;
  124. esac
  125. }
  126.  
  127. # HAL ======================================================================#Q
  128. function q_hal {
  129. dialog --yesno "HAL is a daemon that allows desktop applications to readily access hardware information so that they can locate and use such hardware regardless of bus or device type (It is dependicity for network). Do you wish to install and configure it ?" 10 50
  130. case $? in
  131.   0)
  132.     hal;;
  133.   255)
  134.     last;;
  135. esac
  136. }
  137.  
  138. # GAMIN ====================================================================#Q
  139. function q_gamin {
  140. dialog --yesno "Gamin is used by desktop environments to monitor and report changes to the filesystem. Do you wish to install it ?" 10 50
  141. case $? in
  142.   0)
  143.     pacman -Sy --noconfirm gamin;;
  144.   255)
  145.     last;;
  146. esac
  147. }
  148.  
  149. # GNOME-VOLUME-MANAGER =====================================================#Q
  150. function q_volume_manager {
  151. dialog --yesno "Gnome-volume-manager will automatically mount removable devices as they are connected. Do you wish to install and configure it ?" 10 50
  152. case $? in
  153.   0)
  154.     volman;;
  155.   255)
  156.     last;;
  157. esac
  158. }
  159.  
  160. # ALSA =====================================================================#Q
  161. function q_alsa {
  162. dialog --yesno "Alsa is a Linux kernel component intended to provide device drivers for sound cards. Do you wish to install and configure it ?" 10 50
  163. case $? in
  164.   0)
  165.     alsa;;
  166.   255)
  167.     last;;
  168. esac
  169. }
  170.  
  171. # RECOMENDED ===============================================================#Q
  172. function q_recomended {
  173. dialog --yesno "Do you wish to install recomended software: $reco ?" 10 50
  174. case $? in
  175.   0)
  176.     frecomended;;
  177.   255)
  178.     last;;
  179. esac
  180. }
  181.  
  182. # RECOMENDED ===============================================================#Q
  183. function q_sudo {
  184. dialog --yesno "Do you wish to install sudo? If you chose NO this script may not work the way it should!!!" 10 50
  185. case $? in
  186.   0)
  187.     pacman -S --noconfirm sudo;;
  188.   255)
  189.     last;;
  190. esac
  191. }
  192.  
  193. # MULTIMEDIA ===============================================================#Q
  194. function q_multimedia {
  195. dialog --yesno "Do you wish to install multimedia software: $multi ?" 15 50
  196. case $? in
  197.   0)
  198.     fmultimedia;;
  199.   255)
  200.     last;;
  201. esac
  202. }
  203.  
  204. # INTERNET =================================================================#Q
  205. function q_internet {
  206. dialog --yesno "Do you wish to install internet software: $inter ?" 10 50
  207. case $? in
  208.   0)
  209.     finternet;;
  210.   255)
  211.     last;;
  212. esac
  213. }
  214.  
  215. # OPENBOX-MENU =============================================================#Q
  216. function q_openbox_menu { #####################FOR NOW LAST QUESTION !!!!!!!!!!!!!!!!!!!!!!!!!!!
  217. dialog --yesno "Do you wish to install and configure openbox menu ? Existing menu will be overwritten !!!!!!!!" 10 50
  218. case $? in
  219.   0)
  220.     openbox_menu;;
  221.   255)
  222.     last;;
  223. esac
  224. }
  225.  
  226. # NETWORK ==================================================================#Q
  227. function q_network { #####################FOR NOW LAST QUESTION !!!!!!!!!!!!!!!!!!!!!!!!!!!
  228. dialog --yesno "Do you wish to install and configure wicd (wired and wireless network manager)? If you used gnome-network-manager untill now the script will take care of replacing it." 10 50
  229. case $? in
  230.   0)
  231.     s_network1
  232.     s_network2
  233.     s_network3
  234.     net;;
  235.   255)
  236.     last;;
  237. esac
  238. }
  239.  
  240. # LAPTOP-MODE ==============================================================#Q
  241. function q_laptop_mode { #####################FOR NOW LAST QUESTION !!!!!!!!!!!!!!!!!!!!!!!!!!!
  242. dialog --yesno "Do you wish to install and configure laptop-mode ?" 10 50
  243. case $? in
  244.   0)
  245.     laptop_mode;;
  246.   255)
  247.     last;;
  248. esac
  249. }
  250.  
  251. # LAPTOP-MODE ==============================================================#Q
  252. function q_cpufreq { #####################FOR NOW LAST QUESTION !!!!!!!!!!!!!!!!!!!!!!!!!!!
  253. dialog --yesno "Do you wish to install and configure CPUfreq (set of utilities designed to assist CPU Frequency Scaling) ?" 10 50
  254. case $? in
  255.   0)
  256.     cpufreq;;
  257.   255)
  258.     last;;
  259. esac
  260. }
  261.  
  262. ################################################################################
  263. # FUNCTIONS ====================================================================#
  264. ################################################################################
  265.  
  266.  
  267. # YAOURT ===================================================================#F
  268. function fyaourt {        
  269.                 archfr=`awk '{ printf($3)}' /etc/pacman.conf`
  270.                 if [[ "$archfr" == *http://repo.archlinux.fr/* ]]
  271.                 then echo "Archlinux.fr already exist in repository"
  272.                 else
  273.                 echo "[archlinuxfr]" >> /etc/pacman.conf
  274.                 echo "Server = http://repo.archlinux.fr/$architecture" >> /etc/pacman.conf
  275.                 fi
  276.                 pacman -S --noconfirm yaourt        
  277.                 echo -e "\e[1;33mYaourt installed\e[0m"
  278. }
  279.  
  280. # MULTIMEDIA ===============================================================#F
  281. function fmultimedia {
  282.    pacman -S --noconfirm $multi
  283.                 echo -e "\e[1;33mMultimedia installed\e[0m"
  284. }
  285.  
  286. # INTERNET =================================================================#F
  287. function finternet {
  288.    pacman -S --noconfirm $inter
  289.                 cd /home/$u_name/.config/openbox
  290.                 checkgmail=`awk '{ print($4)}' autostart.sh`
  291.                 if [[ "$checkgmail" != *checkgmail* ]]
  292.                 then
  293.                 cd /home/$u_name/.config/openbox
  294.                 echo "(sleep 4 && checkgmail) &" >> /home/$u_name/.config/openbox/autostart.sh
  295.                 echo -e "\e[1;33mInternet software installed and configured.\e[0m"
  296.                 fi
  297. }
  298.  
  299.  
  300. # RECOMENDED ===============================================================#F
  301. function frecomended {  
  302.    pacman -S --noconfirm $reco
  303.                 echo -e "\e[1;33mRecomended software installed\e[0m"
  304. }
  305.  
  306. # VOLWHEEL =================================================================#F
  307. function volwheel {
  308.    pacman -S --noconfirm volwheel
  309.                 cd /home/$u_name/.config/openbox/
  310.                 volwheel=`awk '{ print($4)}' autostart.sh`
  311.                 if [[ "$volwheel" != *volwheel* ]]
  312.                 then
  313.                 echo "(sleep 2 && volwheel) &" >> /home/$u_name/.config/openbox/autostart.sh
  314.                 echo -e "\e[1;33mVolwheel installed and configured.\e[0m"
  315.                 else
  316.                 echo -e "\e[1;33mVolwheel installed.\e[0m"
  317.                 fi
  318. }
  319.  
  320.  
  321. # BMPANEL ==================================================================#F
  322. function bmpanel {
  323.    yaourt -S --noconfirm bmpanel bmpanel-themes
  324.                 cd /home/$u_name/.config/openbox/
  325.                 bmpan=`awk '{ print($4)}' autostart.sh`            
  326.                 if [[ "$bmpan" != *bmpanel* ]]
  327.                 then
  328.                 echo "(sleep 2 && bmpanel transpy) &" >> /home/$u_name/.config/openbox/autostart.sh
  329.                 echo -e "\e[1;33mBmpanel installed and configured\e[0m"
  330.                 else
  331.                 echo -e "\e[1;33mBmpanel installed.\e[0m"
  332.                 fi
  333. }
  334.  
  335.  
  336. # XSCREENSAVER =============================================================#F
  337. function xscreen {
  338.    pacman -S --noconfirm xscreensaver
  339.                 cd /home/$u_name/.config/openbox/
  340.                 xscree=`awk '{ print($4)}' autostart.sh`          
  341.                 if [[ "$xscree" != *xscreensaver* ]]
  342.                 then
  343.                 echo "xscreensaver -no-splash &" >> /home/$u_name/.config/openbox/autostart.sh
  344.                 echo -e "\e[1;33mXscreensaver installed and configured\e[0m"
  345.                 else
  346.                 echo -e "\e[1;33mXscreensaver installed.\e[0m"
  347.                 fi
  348. }
  349.  
  350. # ALSA =====================================================================#F
  351. function alsa {
  352.    pacman -S --noconfirm alsa-lib alsa-utils
  353.       alsaconf
  354.         demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
  355.         if [[ "$demon" != *alsa* ]]
  356.         then
  357.     READ=$(cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")" )
  358.     WRITE="$demon @alsa"
  359.         sed -i s/"$READ"/"$WRITE"/g /etc/rc.conf
  360.         echo -e "\e[1;33mAlsa installed and configured\e[0m"
  361.         else
  362.         echo -e "\e[1;33mAlsa installed.\e[0m"
  363.         fi
  364. }
  365.  
  366. # HAL =======================================================================#F
  367. function hal {
  368.    pacman -S --noconfirm hal dbus pmount
  369.         demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
  370.         if [[ "$demon" != *hal* ]]
  371.         then
  372.         demon1=`cat /etc/rc.conf | grep "DAEMONS=(" |awk '{ print($1)}'`
  373.     READ=$(cat /etc/rc.conf | grep "DAEMONS=(" |awk '{ print($1)}')
  374.     WRITE="$demon1 hal"
  375.         sed -i s/"$READ"/"$WRITE"/g /etc/rc.conf
  376.         echo -e "\e[1;33mHal installed and configured\e[0m"
  377.         else
  378.         echo -e "\e[1;33mHal installed.\e[0m"
  379.         fi
  380. }
  381.  
  382.  
  383. # GNOME-VOLUME-MANAGER =======================================================#F
  384. function volman {
  385.     pacman -Syu --noconfirm gnome-volume-manager
  386.                 cd /home/$u_name/.config/openbox/
  387.                 gvolman=`awk '{ print($4)}' autostart.sh`          
  388.                 if [[ "$gvolman" != *gnome-volume-manager* ]]
  389.                 then
  390.                 echo "gnome-volume-manager &" >> /home/$u_name/.config/openbox/autostart.sh
  391.                 echo -e "\e[1;33mXscreensaver installed and configured\e[0m"
  392.                 else
  393.                 echo -e "\e[1;33mXscreensaver installed.\e[0m"
  394.                 fi
  395. }
  396.  
  397. # NET =======================================================================#F
  398. function net {
  399.   pacman -S --noconfirm wicd dhclient wpa_supplicant hicolor-icon-theme
  400. varible="wicd"
  401. s_demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
  402. if [[ "$s_demon" == *$varible* ]]
  403.    then
  404.       old1="!$varible"
  405.       new1="$varible"
  406.       sed -i s/"$old1"/"$new1"/g /etc/rc.conf
  407.       old2="@$varible"
  408.       new2="$varible"
  409.       sed -i s/"$old2"/"$new2"/g /etc/rc.conf
  410. else
  411.     READ=$(cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")" )
  412.     WRITE="$s_demon wicd"
  413.         sed -i s/"$READ"/"$WRITE"/g /etc/rc.conf
  414.  
  415. fi
  416.         echo -e "\e[1;33mNetwork installed and configured\e[0m"
  417. }
  418.  
  419. function s_network1 {
  420. varible="network"
  421. s_demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
  422. if [[ "$s_demon" == *$varible* ]]
  423.    then
  424.       old1="!$varible"
  425.       new1="$varible"
  426.       sed -i s/"$old1"/"$new1"/g /etc/rc.conf
  427.       old2="@$varible"
  428.       new2="$varible"
  429.       sed -i s/"$old2"/"$new2"/g /etc/rc.conf
  430.       old3="$varible"
  431.       new3="!$varible"
  432.       sed -i s/"$old3"/"$new3"/g /etc/rc.conf
  433. fi
  434. }
  435.  
  436. function s_network2 {
  437. varible="dhcdbd"
  438. s_demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
  439. if [[ "$s_demon" == *$varible* ]]
  440.    then
  441.       old1="!$varible"
  442.       new1="$varible"
  443.       sed -i s/"$old1"/"$new1"/g /etc/rc.conf
  444.       old2="@$varible"
  445.       new2="$varible"
  446.       sed -i s/"$old2"/"$new2"/g /etc/rc.conf
  447.       old3="$varible"
  448.       new3="!$varible"
  449.       sed -i s/"$old3"/"$new3"/g /etc/rc.conf
  450. fi
  451. }
  452.  
  453. function s_network3 {
  454. varible="networkmanager"
  455. s_demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
  456. if [[ "$s_demon" == *$varible* ]]
  457.    then
  458.       old1="!$varible"
  459.       new1="$varible"
  460.       sed -i s/"$old1"/"$new1"/g /etc/rc.conf
  461.       old2="@$varible"
  462.       new2="$varible"
  463.       sed -i s/"$old2"/"$new2"/g /etc/rc.conf
  464.       old3="$varible"
  465.       new3="!$varible"
  466.       sed -i s/"$old3"/"$new3"/g /etc/rc.conf
  467. fi
  468. }
  469.  
  470. # LAPTOP-MODE ==============================================================#F
  471. function laptop_mode {
  472.    pacman -S --noconfirm laptop-mode-tools
  473.         demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
  474.         if [[ "$demon" != *laptop-mode* ]]
  475.         then
  476.     READ=$(cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")" )
  477.     WRITE="$demon @laptop-mode"
  478.         sed -i s/"$READ"/"$WRITE"/g /etc/rc.conf
  479.         echo -e "\e[1;33mLaptop-mode installed and configured\e[0m"
  480.         else
  481.         echo -e "\e[1;33mLaptop-mode installed.\e[0m"
  482.         fi
  483. }
  484. # CPUFREQ ==================================================================#F
  485. function cpufreq {
  486.      pacman -S --noconfirm cpufrequtils
  487.   demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
  488.   modul=`cat /etc/rc.conf | grep "MODULES=(" | tr -d "MODULES=(" | tr -d ")"`
  489.   visud=`cat /etc/sudoers`
  490.  
  491.         if [[ "$demon" != *cpufreq* ]]
  492.         then
  493.     READ=$(cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")" )
  494.     WRITE="$demon @cpufreq"
  495.         sed -i s/"$READ"/"$WRITE"/g /etc/rc.conf
  496.         echo -e "\e[1;33mDeamon for laptop-mode added\e[0m"
  497. fi
  498.  
  499.         if [[ "$modul" != *cpufreq* ]]
  500.         then
  501.     READ=$(cat /etc/rc.conf | grep "MODULES=(" | tr -d "MODULES=(" | tr -d ")" )
  502.     WRITE="$modul acpi-cpufreq cpufreq_powersave cpufreq_ondemand"
  503.         sed -i s/"$READ"/"$WRITE"/g /etc/rc.conf
  504.         echo -e "\e[1;33mModule for laptop-mode added\e[0m"
  505. fi
  506.         if [[ "$visud" != *cpufreq* ]]
  507.         then
  508.         echo "ALL    ALL=NOPASSWD:/etc/rc.d/cpufreq-set" >> /etc/sudoers
  509.         echo "ALL    ALL=NOPASSWD:/etc/rc.d/cpufreq" >> /etc/sudoers
  510. fi
  511.  echo "To make shure everything is ok with CPUfreq check: rc.conf (modules,deamons) and also if you have sudo premission (visudo)." >> /home/$u_name/README
  512.  echo "To use on demand governor use #sudo cpufreq-set -g ondemand" >> /home/$u_name/README
  513.  echo "To use powersave governor use #sudo cpufreq-set -g powersave" >> /home/$u_name/README
  514. }
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524. # VISUDO ===================================================================#F   ############### NOT YET #############
  525. function visudo {
  526. echo "#%power  ALL=(ALL) NOPASSWD: /usr/sbin/pm-hibernate" >> /etc/sudoers
  527. }
  528.  
  529. # OPENBOX-MENU =============================================================#F
  530. function openbox_menu {
  531.     pacman -Syu --noconfirm menumaker obconf
  532.     mmaker -vf OpenBox3
  533. }
  534.  
  535.  
  536. # OPENBOX-MENU =============================================================#F
  537. function readme {
  538. rm /home/$u_name/README
  539. echo "# A script to automate installation and configuration of ArchLinux" >> /home/$u_name/README
  540. echo "# Author: Jakadinho" >> /home/$u_name/README
  541. echo "# v0.1.1" >> /home/$u_name/README
  542. echo "# ======================================================================== #" >> /home/$u_name/README
  543.  
  544. }
  545.  
  546.  
  547. function last {
  548. #### AT THE END
  549. rm /tmp/u_name
  550. rm /tmp/user_ch
  551. rm /tmp/archite
  552. #Return ownership to the approtiate users
  553. chown -R $u_name:users /home/$u_name/
  554. chmod -R 750 /home/$u_name/.config/openbox
  555. chmod -R 750 /home/$u_name/.config/README
  556. echo -e "\e[1;31mALL DONE !!!!\e[0m"
  557. echo -e "\e[1;33mRead /home/$u_name/README !!!!\e[0m"
  558.  
  559. exit
  560. }
  561.  
  562. ### START
  563. q_update
  564. q_user
  565. readme
  566. q_architecture
  567. q_sudo
  568. q_hal           #+deamon
  569. q_cpufreq       #+deamon +module +visudo
  570. q_network       #+deamon
  571. q_alsa          #+deamon
  572. q_laptop_mode   #+deamon
  573. #slim
  574. q_yaourt
  575. q_volwheel
  576. q_bmpanel
  577. q_xscreen
  578. q_gamin
  579. q_volume_manager
  580. q_alsa
  581. q_multimedia
  582. q_recomended
  583. q_internet
  584. q_openbox_menu
  585.  
  586.  
  587. last
  588.  
  589.  
  590.  
  591.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement