You are not logged in.

#1 2008-09-28 19:19:57

Black Mage
Member
Registered: 2008-09-17
Posts: 32

My post installation script

#I hope its the right forum to post that in, if not im very sorry!

This here is a script i wrote to automate all the stuff i do after installing arch, i have several computers and it has options for a additional one

Some important points:

1) this script is very specific, its made for my computer and my needs, this means that its useful right now only to people who know bash
and will find use in altering it to their own needs, also if someone wants he can make it more general for a wider use
2) this is one of the first scripts i wrote, it may be that it doesn't implent some of its features in the best way possible
3) use it at your own risk, if it breaks your system don't blame me please, you should check it before you use it, anyway its meant to be used
on a FRESH arch install, not on a working system.

What the correct script actually does:

The script as stated in the comments does the next things:

1) First of all it consists of several files, one the "install" file is the actual script, the others are just meant to run the script and split its output to
show both on the terminal and in a file named: /var/log/MySysInstall.log, here is an example of main.install:

#!/bin/bash

./install Main | tee /var/log/MySysInstall.log

in the current script Main in the last row can be replaces with Laptop, Game for computer specific arguments or without argumets for a general install
the two files should be in the same folder, i think it could have been implented with one file but im new to scripting..
2) The script will ask some general questions to make sure everything is currect, some of the questions and checks in the script are not relevant at all
to anybody other than myself, they usually make sure that i have a samba shared partition running (it could lose connection on wireless).
3) Adds the archlinux.fr repo, it will be used for yaourt.
4) The script installs lots of stuff, at first general stuff used by all computers in my house, then stuff based on the argument given in 1)
please inspect the packages and change according to your needs
5) The script nano's to /etc/yaourtrc
6) Adds users to the system, change to your users.
7) It creates my /home/samba share dir if its not created (probably irrelevant to you)
8) Configures sudo in a nasty way that maybe can damage the sudoers file, delete this line if you dodnt know sudo well enough.
9) Edits samba if needed, this is the first line in the script that relies on additional files i have on my comp or the samba share (main and game are the same
comp (dual boot of arch32 and 64) and they are the hosts of /home/samba all the other computers will mount it from them, this is why a samba check is not
present here.).
10) Adds some commented lines to fstab and nano's it for easier configurations, this is the regular workflow in the script BTW (adding comments to the file
before editing it)
11) Helps edit the gpm daemon
12) Helps to configure alsa
13) Helps to configure xorg
14) Does some post install copies of files AND creates a file in my main users home with further instructions, mostly for stuff that needs to be done with xorg runnig
or stuff i was to lasy to add to the script tongue
15) chowns and sets my regular permissions for user folders
16) ends the script smile

The script itself, ENJOY:

#!/bin/bash

# Copyright 2008 Leon Vayman
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# A copy of the GNU General Public License is found in
# <http://www.gnu.org/licenses/>.


#Check that the user updated the kernel and restarted before proceeding
while [ 1 ] ; do
    echo ; clear
    echo -n "Have you already used pacman -Syu and Restarted? (y/n) "
    read Keypress
        case "$Keypress" in
            [Yy]) 
                break
                ;;
            [Nn])
                echo "Then do it now.."
                exit
                ;;    
            *) 
                ;;
        esac
done

#Check if samba is accesible and warn the user if its not (offering to quit)
if [ ! -e /home/samba/Config/ ] ; then
    while [ 1 ] ; do
        echo ; clear
        echo -n "Samba is not accesible, do you want to proceed? (y/n) "
        read Keypress
            case "$Keypress" in
                [Yy]) 
                    break
                    ;;
                [Nn])
                    exit
                    ;;    
                *) 
                    ;;
            esac
    done
fi

#Make sure the app wasnt ran accidently with wrong arguments
while [ 1 ] ; do
    echo ; clear
    echo -n "The comp you are on is $1 is that correct? (y/n) "
    read Keypress
        case "$Keypress" in
            [Yy]) 
                break
                ;;
            [Nn])
                exit
                ;;    
            *) 
                ;;
        esac
done

#Edit /etc/pacman.conf
echo ; clear
echo >> /etc/pacman.conf
echo "[archlinuxfr]" >> /etc/pacman.conf
if [ "$1" = "Game" ] ; then
    echo "Server = http://repo.archlinux.fr/x86_64" >> /etc/pacman.conf
else
    echo "Server = http://repo.archlinux.fr/i686" >> /etc/pacman.conf
fi
echo -n "Make sure the right archlinux.fr repo was added "
read n1
nano /etc/pacman.conf
echo ; clear

#Install all packages
echo "Installing packages"
pacman -Syu
pacman -S yaourt
pacman -S xorg
pacman -S gstreamer0.10-plugins
yaourt -S abiword alsa-lib alsa-utils alsa-oss bash-completion cabextract centerim conky exaile hal epdfview feh freetype2 gamin gconf-editor geany gksu gmrun gnome-icon-theme gpicview \
gtk-engines zip irssi jre links-g libdvdcss tcl lxappearance lxpanel lxde-common lxrandr lxtask mesa moc mousepad mplayer-plugin numlockx openbox obconf obmenu openbox-themes \
p7zip pcmanfm pidgin pm-utils powertop screen terminal ttf-bitstream-vera ttf-dejavu ttf-freefont ttf-ms-fonts unace unrar unzip xarchiver xchat xmahjongg
yaourt -S stjerm
case "$1" in
    "Laptop")
        yaourt -S vlc keytouch keytouch-editor xf86-video-i810 synaptics cpufrequtils flashplugin
        yaourt -S swiftweasel-pentium-3
        yaourt -S wpa_supplicant-beta
        yaourt -S xcompmgr-git
        ;;
    "Main")
        yaourt -S flashplugin cpufrequtils epiphany catalyst deluge amule xmoto abs samba
        yaourt -S icecat
        yaourt -S xcompmgr-git
        yaourt -S ekiga3
        yaourt -S ov51x-jpeg
        yaourt -S vlc-branch
        yaourt -S brasero-no-gnome
        ;;
    "Game")
        yaourt -S epiphany catalyst deluge amule xmoto abs samba ##!! add gnash or swfdec
        yaourt -S icecat
        yaourt -S ekiga3
        yaourt -S ov51x-jpeg
        yaourt -S vlc-branch
        yaourt -S brasero-no-gnome
        ;;
    *)
        echo -n "No extra packages installed "
        ;;
esac
echo -n "Press Enter to continue "
read n1
echo ; clear

#Configure yaourt.rc
echo -n "Replace the editor in yaourtrc "
read n1
nano /etc/yaourtrc
echo ; clear

#Add users
echo "Adding User vleon"
useradd -d /home/vleon -g users -G disk,wheel,games,video,audio,optical,storage,power,dbus,hal,avahi,log -m vleon
echo "Set vleon's password"
passwd vleon
echo ; clear
echo "Adding User masha"
useradd -d /home/masha -g users -G disk,wheel,games,video,audio,optical,storage,power,dbus,hal,avahi,log -m masha
echo "Set masha's password"
passwd masha
echo ; clear

#If for some reason samba dir doesnt exist, create it
if [ ! -e /home/samba ] ; then
    mkdir /home/samba
    chown vleon:users /home/samba
    chmod 770 /home/samba
fi

#Configure visudo
echo -n "uncomment wheel in visudo and make sure the added lines are correct "
read n1
echo "#%power  ALL=(ALL) NOPASSWD: /usr/sbin/pm-hibernate" >> /etc/sudoers
echo "#%power  ALL=(ALL) NOPASSWD: /sbin/shutdown" >> /etc/sudoers
visudo
echo ; clear

#Edit samba if needed
if ( [ "$1" = "Main" ] || [ "$1" = "Game" ] ) ; then
    echo -n "Edit swat "
    read n1
    cp /home/samba/Config/etc/xinetd.d/swat /etc/xinetd.d/swat
    nano /etc/xinetd.d/swat
    echo ; clear
    echo -n "Edit Hosts "
    read n1
    cp /home/samba/Config/etc/hosts.allow /etc/hosts.allow
    nano /etc/hosts.allow
    echo ; clear
    echo -n "Edit smb.conf "
    read n1
    cp /home/samba/Config/etc/samba/smb.conf /etc/samba/smb.conf
    nano /etc/samba/smb.conf
    echo ; clear
    echo "Set vleon's samba password"
    smbpasswd -a vleon
    echo ; clear
    echo -n "Add samba and xinetd daemon to rc.conf "
    read n1
    nano /etc/rc.conf
    echo ; clear
fi

#Edit fstab
echo -n "Edit fstab "
read n1
echo >> /etc/fstab
if  [ "$1" != "Laptop" ] ; then
    echo "#UUID=92D8DA69D8DA4ADD /mnt/windows ntfs-3g defaults,noatime 0 0" >> /etc/fstab
    if  ( [ "$1" != "Main" ] && [ "$1" != "Game" ] ) ; then
        echo "#UUID=0E15-1D06 /mnt/windows vfat defaults,noatime,umask=0000 0 0" >> /etc/fstab
        echo "#//192.168.1.100/samba /home/samba cifs defaults,noatime,noauto,user=vleon%pass 0 0" >> /etc/fstab
        echo "##change the above password!!" >> /etc/fstab
    fi
    nano /etc/fstab
    echo ; clear
else
    echo "#UUID=0E15-1D06 /mnt/windows vfat defaults,noatime,umask=0000 0 0" >> /etc/fstab
    echo "#//192.168.1.100/samba /home/samba cifs defaults,noatime,noauto,user=vleon%pass 0 0" >> /etc/fstab
    echo "##change the above password!!" >> /etc/fstab
    nano /etc/fstab
    echo ; clear
fi

#Edit gpm
echo -n "Edit gpm "
read n1
echo "#GPM_ARGS=\"-m /dev/input/mice -t imps2\"" >> /etc/conf.d/gpm
nano /etc/conf.d/gpm
echo ; clear
echo -n "Add gpm daemon to rc.conf "
read n1
nano /etc/rc.conf
echo ; clear

#Configure alsa
Alsa Config
test=1
echo -n "Edit alsamixer "
read n1
while [ "$test" = 1 ] ; do
    alsamixer -V all
    echo "Testing Sound"
    aplay /usr/share/sounds/alsa/Noise.wav
    while [ 1 ] ; do
    echo ; clear
    echo -n "Did You Hear Any Sound? (y/n) "
    read Keypress
        case "$Keypress" in
            [Yy]) 
                test=0
                break
                ;;
            [Nn])
                break
                ;;
            *) 
                ;;
        esac
    done
done 
alsactl store
echo -n "Add alsa to daemons "
read n1
nano /etc/rc.conf
echo ; clear

#Configure Xorg
if [ -e /home/samba/Config/etc/X11/ ] ; then
    echo -n "Edit xorg.conf "
    read n1
    if ( [ "$1" = "Laptop" ] ) ; then
        cp /home/samba/Config/etc/X11/laptop.xorg.conf /etc/X11/xorg.conf
    else
        cp /home/samba/Config/etc/X11/main.xorg.conf /etc/X11/xorg.conf
    fi
    nano /etc/X11/xorg.conf
    echo ; clear

    echo -n "add \"ru\" to xorg.conf.mom "
    read n1
    cp etc/X11/xorg.conf etc/X11/xorg.conf.mom
    nano /etc/X11/xorg.conf.mom
    echo ; clear
else
    echo -n "No samba connection found, manually editing xorg.conf "
    read n1
    X -configure
    mv /root/xorg.conf.new /etc/X11/xorg.conf
    echo >> /etc/X11/xorg.conf
    echo "#      Option      \"XkbLayout\" \"us,il\"" >> /etc/X11/xorg.conf
    echo "#      Option      \"XkbOptions\" \"grp:alt_shift_toggle,grp_led:scroll\"" >> /etc/X11/xorg.conf
    echo "#    DefaultDepth 24" >> /etc/X11/xorg.conf
    echo "#        Modes      \"1680x1050\" \"1280x1024\" \"1024x768\" \"800x600\"" >> /etc/X11/xorg.conf
    if [ "$1" = "Laptop" ] ; then
        echo >> /etc/X11/xorg.conf
        echo "#Section \"InputDevice\"" >> /etc/X11/xorg.conf
        echo "#    Identifier      \"Touchpad\"" >> /etc/X11/xorg.conf
        echo "#    Driver          \"synaptics\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"Device\"        \"/dev/input/mouse0\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"Protocol\"      \"auto-dev\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"LeftEdge\"      \"1700\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"RightEdge\"     \"5300\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"TopEdge\"       \"1700\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"BottomEdge\"    \"4200\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"FingerLow\"     \"25\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"FingerHigh\"    \"30\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"FingerPress\"   \"100\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"MaxTapTime\"    \"180\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"MaxTapMove\"    \"220\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"VertScrollDelta\" \"100\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"MinSpeed\"      \"0.06\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"MaxSpeed\"      \"0.12\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"AccelFactor\" \"0.0010\"" >> /etc/X11/xorg.conf
        echo "#    Option  \"SHMConfig\"     \"on\"" >> /etc/X11/xorg.conf
        echo "#EndSection" >> /etc/X11/xorg.conf
    fi
    echo -n "Edit xorg.conf "
    read n1
    nano /etc/X11/xorg.conf
    echo ; clear
    echo -n "add \"ru\" to xorg.conf.mom "
    read n1
    cp etc/X11/xorg.conf etc/X11/xorg.conf.mom
    nano /etc/X11/xorg.conf.mom
    echo ; clear
fi

#Start the post install document and copy files to homes if able and need to
echo "Post Installation Instructions" > /home/vleon/PostInstall.txt
echo "------------------------------" >> /home/vleon/PostInstall.txt
echo >> /home/vleon/PostInstall.txt
echo "Usage: Follow the instructions and delete the lines that are not relevant anymore. you can delete" >> /home/vleon/PostInstall.txt
echo "       this file after you finished." >> /home/vleon/PostInstall.txt
echo >> /home/vleon/PostInstall.txt
echo "-------------------------------------------------------------------------------------------------" >> /home/vleon/PostInstall.txt
if [ ! -e /home/vleon/.config] ; then
    if [ -e /home/samba/Config/ ] ; then
        cp /home/samba/Config/.bash_profile /home/vleon/ ; cp /home/samba/Config/.bash_profile /home/masha/
        cp /home/samba/Config/.bashrc /home/vleon/ ; cp /home/samba/Config/.bashrc /home/masha/
        cp /home/samba/Config/.xinitrc /home/vleon/ ; cp /home/samba/Config/.xinitrc /home/masha/
        cp /home/samba/Config/.xserverrc /home/masha/
        mkdir -p /home/vleon/.config/openbox ; mkdir -p /home/masha/.config/openbox
        cp /home/samba/Config/.config/openbox/rc.xml /home/vleon/.config/openbox/ ; cp /home/samba/Config/.config/openbox/rc.xml /home/masha/.config/openbox/
        if [ "$1" = "Laptop" ] ; then
            cp /home/samba/Config/.conkyrc.laptop /home/vleon/.conkyrc ; cp /home/samba/Config/.conkyrc.laptop /home/masha/.conkyrc
            cp /home/samba/Config/.Xdefaults.laptop /home/vleon/.Xdefaults ; cp /home/samba/Config/.Xdefaults.laptop /home/masha/.Xdefaults
            cp /home/samba/Config/.config/openbox/menu.xml.laptop /home/vleon/.config/openbox/menu.xml 
            cp /home/samba/Config/.config/openbox/menu.xml.laptop /home/masha/.config/openbox/menu.xml
            cp /home/samba/Config/.config/openbox/autostart.sh.laptop /home/vleon/.config/openbox/autostart.sh
            cp /home/samba/Config/.config/openbox/autostart.sh.laptop /home/masha/.config/openbox/autostart.sh
        else
            if ( [ "$1" != "Main" ] && [ "$1" != "Game" ] )
                cp /home/samba/Config/.conkyrc.laptop /home/vleon/.conkyrc ; cp /home/samba/Config/.conkyrc.laptop /home/masha/.conkyrc
            else
                cp /home/samba/Config/.conkyrc.main /home/vleon/.conkyrc ; cp /home/samba/Config/.conkyrc.main /home/masha/.conkyrc
            fi
            cp /home/samba/Config/.Xdefaults.main /home/vleon/.Xdefaults ; cp /home/samba/Config/.Xdefaults.main /home/masha/.Xdefaults
            cp /home/samba/Config/.config/openbox/menu.xml.main /home/vleon/.config/openbox/menu.xml 
            cp /home/samba/Config/.config/openbox/menu.xml.main /home/masha/.config/openbox/menu.xml
            cp /home/samba/Config/.config/openbox/autostart.sh.main /home/vleon/.config/openbox/autostart.sh
            cp /home/samba/Config/.config/openbox/autostart.sh.main /home/masha/.config/openbox/autostart.sh    
        fi
    else
        echo >> /home/vleon/PostInstall.txt
        echo "!!Samba is not availble, you will have to create the following files yourself!!" >> /home/vleon/PostInstall.txt
    fi        
echo >> /home/vleon/PostInstall.txt
echo "The folowing files where probably created in your home folders:" >> /home/vleon/PostInstall.txt
echo ".bash_profile" >> /home/vleon/PostInstall.txt
echo ".bashrc" >> /home/vleon/PostInstall.txt
echo ".conkyrc" >> /home/vleon/PostInstall.txt
echo ".Xdefaults" >> /home/vleon/PostInstall.txt
echo ".xinitrc" >> /home/vleon/PostInstall.txt
echo ".xserverrc #<< only to /home/masha" >> /home/vleon/PostInstall.txt
echo ".config/openbox/autostart.sh" >> /home/vleon/PostInstall.txt
echo ".config/openbox/menu.xml" >> /home/vleon/PostInstall.txt
echo ".config/openbox/rc.xml" >> /home/vleon/PostInstall.txt
echo "!!Make sure the above files created and are configured properly!!" >> /home/vleon/PostInstall.txt
echo >> /home/vleon/PostInstall.txt
echo "Configuration Guidelines:" >> /home/vleon/PostInstall.txt
echo "1) make sure width and hight are correct .Xdefaults" >> /home/vleon/PostInstall.txt
echo "2) make sure to comment the \"xcompmgr\" line in autostart.sh, to fit the Computer and User" >> /home/vleon/PostInstall.txt
echo "3) use obmenu and obconf later to tune up stuff" >> /home/vleon/PostInstall.txt
echo >> /home/vleon/PostInstall.txt
echo "-------------------------------------------------------------------------------------------------" >> /home/vleon/PostInstall.txt
echo >> /home/vleon/PostInstall.txt
echo "rc.conf Guidelines:" >> /home/vleon/PostInstall.txt
echo "1) possible modules are: powernow-k8 or acpi-cpufreq, cpufreq_ondemand, ov51x-jpeg, fglrx" >> /home/vleon/PostInstall.txt
echo "2) possible daemons are: hal, cpufreq, acpid [laptop], netfs, keytouch" >> /home/vleon/PostInstall.txt
echo >> /home/vleon/PostInstall.txt
echo "-------------------------------------------------------------------------------------------------" >> /home/vleon/PostInstall.txt
echo >> /home/vleon/PostInstall.txt
echo "General Guidelines:" >> /home/vleon/PostInstall.txt
echo "1) copy or compare the files from /home/samba/Config/etc to /etc" >> /home/vleon/PostInstall.txt
echo "2) on the laptop, dont forget to add the additional scripts needed from the /home/samba/Config/, dont forget to backup replaced files" >> /home/vleon/PostInstall.txt
echo "3) add resume=/dev/sda3 to /boot/grub/menu.lst if its not there already" >> /home/vleon/PostInstall.txt
echo "4) dont Forget to configure gksu after launching X" >> /home/vleon/PostInstall.txt
echo "5) lauch and configure all the apps in the menu and the cmdline apps links -g, mocp, irssi, centerim" >> /home/vleon/PostInstall.txt
echo "6) test logout, reboot, shutdown and hibernate" >> /home/vleon/PostInstall.txt
echo "7) configure keytouch on the laptop" >> /home/vleon/PostInstall.txt
echo "8) if it doesnt exist mkdir ~/.Theme for both users and add a jpg picture named theme.jpg to be the wallpaper" >> /home/vleon/PostInstall.txt
echo "9) read /var/log/MySysInstall.log and make sure all was succesfull especialy AUR install's like icecat or iceweasel" >> /home/vleon/PostInstall.txt
echo "10) run lxappearance, configure lxpanel, configure terminal" >> /home/vleon/PostInstall.txt 
echo "11) run powertop after you restart again with all the modules and daemons and other stuff configured" >> /home/vleon/PostInstall.txt 

#Return ownership to the approtiate users
chown -R vleon:users /home/vleon ; chown -R masha:users /home/masha
chmod /home/vleon 750 ; chmod /home/masha 750
chmod /home/vleon/.config 750 ; chmod /home/masha/config 750
chmod /home/vleon/.config/openbox 750 ; chmod /home/vleon/.config/openbox 750

#End
echo "Install Finished, please additional instructions where created in /home/vleon/PostInstall.txt"
read n1
exit

Offline

#2 2008-10-01 06:10:34

darthaxul
Member
Registered: 2008-09-24
Posts: 156

Re: My post installation script

that scipt is nothing compared to mine.
I use 4 diffrent scripts that would be too long and too boring to post here.

Offline

#3 2008-10-01 06:13:36

Black Mage
Member
Registered: 2008-09-17
Posts: 32

Re: My post installation script

im very happy for you.

i actually almost finished a rewrite of the script, this one is very general, i think its the wrong forum so ill post a new post with
the new script, and give a link from here.

Offline

#4 2008-10-01 09:24:01

Black Mage
Member
Registered: 2008-09-17
Posts: 32

Re: My post installation script

Offline

#5 2009-08-21 02:36:33

luckystar09
Member
Registered: 2009-08-21
Posts: 1

Re: My post installation script

I'm very interested! I would love to find out more.
script install

Offline

#6 2009-08-21 06:20:49

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: My post installation script

luckystar09 - I'd say you're on your own there. This thread is nearly a year old, and Black Mage hasn't posted here since. Read the script, and modify it yourself as required.

Forum rule - do not post in threads that have been inactive for six months of more. See here for full details.

Closed.

Offline

Board footer

Powered by FluxBB