#!/bin/bash
# A script to automate installation and configuration of ArchLinux
# Author: Jakadinho
# v0.1.1
# ======================================================================== #
# Run this script as root.
user=$UID
if [ $user != 0 ]
then
echo -e "\e[1;31mSorry. Only ROOT user can run this program !\e[0m"
exit
fi
################################################################################
# PACKETS== ====================================================================#
################################################################################
# Edit in order to change installed packages.
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"
reco="sakura gedit"
inter="firefox deluge skype pidgin checkgmail" #if you remove checkgmail you also have to edit function "finternet" (line 282)
################################################################################
# QUESTIONS ====================================================================#
################################################################################
# UPDATE ===================================================================#Q
function q_update {
dialog --yesno "Did you recently update system (pacman -Syu) ?" 10 50
case $? in
1)
pacman -Syu --noconfirm;;
255)
last;;
esac
}
# USERNAME =================================================================#Q
function q_user {
dialog \
--menu "Select one option:" 12 60 5 \
1 "Use existing user" \
2 "Create new user" 2>/tmp/user_ch
user_choice="`cat /tmp/user_ch`"
if [[ "$user_choice" == 2 ]]
then
q_newuser
fi
if [[ "$user_choice" == 1 ]]
then
q_username
fi
}
function q_newuser {
dialog --inputbox "Please enter desired username): " 15 40 2>/tmp/u_name
u_name="`cat /tmp/u_name`"
useradd -m -G users,audio,lp,optical,storage,video,wheel,power -s /bin/bash $u_name
echo "Set $u_name's password"
passwd $u_name
}
function q_username {
dialog --inputbox "Please enter your username (openbox config will be written only for this user!!!!): " 15 40 2>/tmp/u_name
u_name="`cat /tmp/u_name`"
}
# ARCHITECTURE =============================================================#Q
function q_architecture {
dialog \
--menu "Select witch architecture you use:" 12 60 5 \
"i686" "1" \
"x86_64" "2" 2>/tmp/archite
architecture="`cat /tmp/archite`"
}
# YAOURT ===================================================================#Q
function q_yaourt {
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
case $? in
0)
fyaourt;;
255)
last;;
esac
}
# VOLWHEEL =================================================================#Q
function q_volwheel {
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
case $? in
0)
volwheel;;
255)
last;;
esac
}
# BMPANEL ==================================================================#Q
function q_bmpanel {
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
case $? in
0)
bmpanel;;
255)
last;;
esac
}
# XSCREENSAVER =============================================================#Q
function q_xscreen {
dialog --yesno "Xscreensaver is screen saver and locker for the X Window System. Do you wish to install and configure it ?" 10 50
case $? in
0)
xscreen;;
255)
last;;
esac
}
# HAL ======================================================================#Q
function q_hal {
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
case $? in
0)
hal;;
255)
last;;
esac
}
# GAMIN ====================================================================#Q
function q_gamin {
dialog --yesno "Gamin is used by desktop environments to monitor and report changes to the filesystem. Do you wish to install it ?" 10 50
case $? in
0)
pacman -Sy --noconfirm gamin;;
255)
last;;
esac
}
# GNOME-VOLUME-MANAGER =====================================================#Q
function q_volume_manager {
dialog --yesno "Gnome-volume-manager will automatically mount removable devices as they are connected. Do you wish to install and configure it ?" 10 50
case $? in
0)
volman;;
255)
last;;
esac
}
# ALSA =====================================================================#Q
function q_alsa {
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
case $? in
0)
alsa;;
255)
last;;
esac
}
# RECOMENDED ===============================================================#Q
function q_recomended {
dialog --yesno "Do you wish to install recomended software: $reco ?" 10 50
case $? in
0)
frecomended;;
255)
last;;
esac
}
# RECOMENDED ===============================================================#Q
function q_sudo {
dialog --yesno "Do you wish to install sudo? If you chose NO this script may not work the way it should!!!" 10 50
case $? in
0)
pacman -S --noconfirm sudo;;
255)
last;;
esac
}
# MULTIMEDIA ===============================================================#Q
function q_multimedia {
dialog --yesno "Do you wish to install multimedia software: $multi ?" 15 50
case $? in
0)
fmultimedia;;
255)
last;;
esac
}
# INTERNET =================================================================#Q
function q_internet {
dialog --yesno "Do you wish to install internet software: $inter ?" 10 50
case $? in
0)
finternet;;
255)
last;;
esac
}
# OPENBOX-MENU =============================================================#Q
function q_openbox_menu { #####################FOR NOW LAST QUESTION !!!!!!!!!!!!!!!!!!!!!!!!!!!
dialog --yesno "Do you wish to install and configure openbox menu ? Existing menu will be overwritten !!!!!!!!" 10 50
case $? in
0)
openbox_menu;;
255)
last;;
esac
}
# NETWORK ==================================================================#Q
function q_network { #####################FOR NOW LAST QUESTION !!!!!!!!!!!!!!!!!!!!!!!!!!!
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
case $? in
0)
s_network1
s_network2
s_network3
net;;
255)
last;;
esac
}
# LAPTOP-MODE ==============================================================#Q
function q_laptop_mode { #####################FOR NOW LAST QUESTION !!!!!!!!!!!!!!!!!!!!!!!!!!!
dialog --yesno "Do you wish to install and configure laptop-mode ?" 10 50
case $? in
0)
laptop_mode;;
255)
last;;
esac
}
# LAPTOP-MODE ==============================================================#Q
function q_cpufreq { #####################FOR NOW LAST QUESTION !!!!!!!!!!!!!!!!!!!!!!!!!!!
dialog --yesno "Do you wish to install and configure CPUfreq (set of utilities designed to assist CPU Frequency Scaling) ?" 10 50
case $? in
0)
cpufreq;;
255)
last;;
esac
}
################################################################################
# FUNCTIONS ====================================================================#
################################################################################
# YAOURT ===================================================================#F
function fyaourt {
archfr=`awk '{ printf($3)}' /etc/pacman.conf`
if [[ "$archfr" == *http://repo.archlinux.fr/* ]]
then echo "Archlinux.fr already exist in repository"
else
echo "[archlinuxfr]" >> /etc/pacman.conf
echo "Server = http://repo.archlinux.fr/$architecture" >> /etc/pacman.conf
fi
pacman -S --noconfirm yaourt
echo -e "\e[1;33mYaourt installed\e[0m"
}
# MULTIMEDIA ===============================================================#F
function fmultimedia {
pacman -S --noconfirm $multi
echo -e "\e[1;33mMultimedia installed\e[0m"
}
# INTERNET =================================================================#F
function finternet {
pacman -S --noconfirm $inter
cd /home/$u_name/.config/openbox
checkgmail=`awk '{ print($4)}' autostart.sh`
if [[ "$checkgmail" != *checkgmail* ]]
then
cd /home/$u_name/.config/openbox
echo "(sleep 4 && checkgmail) &" >> /home/$u_name/.config/openbox/autostart.sh
echo -e "\e[1;33mInternet software installed and configured.\e[0m"
fi
}
# RECOMENDED ===============================================================#F
function frecomended {
pacman -S --noconfirm $reco
echo -e "\e[1;33mRecomended software installed\e[0m"
}
# VOLWHEEL =================================================================#F
function volwheel {
pacman -S --noconfirm volwheel
cd /home/$u_name/.config/openbox/
volwheel=`awk '{ print($4)}' autostart.sh`
if [[ "$volwheel" != *volwheel* ]]
then
echo "(sleep 2 && volwheel) &" >> /home/$u_name/.config/openbox/autostart.sh
echo -e "\e[1;33mVolwheel installed and configured.\e[0m"
else
echo -e "\e[1;33mVolwheel installed.\e[0m"
fi
}
# BMPANEL ==================================================================#F
function bmpanel {
yaourt -S --noconfirm bmpanel bmpanel-themes
cd /home/$u_name/.config/openbox/
bmpan=`awk '{ print($4)}' autostart.sh`
if [[ "$bmpan" != *bmpanel* ]]
then
echo "(sleep 2 && bmpanel transpy) &" >> /home/$u_name/.config/openbox/autostart.sh
echo -e "\e[1;33mBmpanel installed and configured\e[0m"
else
echo -e "\e[1;33mBmpanel installed.\e[0m"
fi
}
# XSCREENSAVER =============================================================#F
function xscreen {
pacman -S --noconfirm xscreensaver
cd /home/$u_name/.config/openbox/
xscree=`awk '{ print($4)}' autostart.sh`
if [[ "$xscree" != *xscreensaver* ]]
then
echo "xscreensaver -no-splash &" >> /home/$u_name/.config/openbox/autostart.sh
echo -e "\e[1;33mXscreensaver installed and configured\e[0m"
else
echo -e "\e[1;33mXscreensaver installed.\e[0m"
fi
}
# ALSA =====================================================================#F
function alsa {
pacman -S --noconfirm alsa-lib alsa-utils
alsaconf
demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
if [[ "$demon" != *alsa* ]]
then
READ=$(cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")" )
WRITE="$demon @alsa"
sed -i s/"$READ"/"$WRITE"/g /etc/rc.conf
echo -e "\e[1;33mAlsa installed and configured\e[0m"
else
echo -e "\e[1;33mAlsa installed.\e[0m"
fi
}
# HAL =======================================================================#F
function hal {
pacman -S --noconfirm hal dbus pmount
demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
if [[ "$demon" != *hal* ]]
then
demon1=`cat /etc/rc.conf | grep "DAEMONS=(" |awk '{ print($1)}'`
READ=$(cat /etc/rc.conf | grep "DAEMONS=(" |awk '{ print($1)}')
WRITE="$demon1 hal"
sed -i s/"$READ"/"$WRITE"/g /etc/rc.conf
echo -e "\e[1;33mHal installed and configured\e[0m"
else
echo -e "\e[1;33mHal installed.\e[0m"
fi
}
# GNOME-VOLUME-MANAGER =======================================================#F
function volman {
pacman -Syu --noconfirm gnome-volume-manager
cd /home/$u_name/.config/openbox/
gvolman=`awk '{ print($4)}' autostart.sh`
if [[ "$gvolman" != *gnome-volume-manager* ]]
then
echo "gnome-volume-manager &" >> /home/$u_name/.config/openbox/autostart.sh
echo -e "\e[1;33mXscreensaver installed and configured\e[0m"
else
echo -e "\e[1;33mXscreensaver installed.\e[0m"
fi
}
# NET =======================================================================#F
function net {
pacman -S --noconfirm wicd dhclient wpa_supplicant hicolor-icon-theme
varible="wicd"
s_demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
if [[ "$s_demon" == *$varible* ]]
then
old1="!$varible"
new1="$varible"
sed -i s/"$old1"/"$new1"/g /etc/rc.conf
old2="@$varible"
new2="$varible"
sed -i s/"$old2"/"$new2"/g /etc/rc.conf
else
READ=$(cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")" )
WRITE="$s_demon wicd"
sed -i s/"$READ"/"$WRITE"/g /etc/rc.conf
fi
echo -e "\e[1;33mNetwork installed and configured\e[0m"
}
function s_network1 {
varible="network"
s_demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
if [[ "$s_demon" == *$varible* ]]
then
old1="!$varible"
new1="$varible"
sed -i s/"$old1"/"$new1"/g /etc/rc.conf
old2="@$varible"
new2="$varible"
sed -i s/"$old2"/"$new2"/g /etc/rc.conf
old3="$varible"
new3="!$varible"
sed -i s/"$old3"/"$new3"/g /etc/rc.conf
fi
}
function s_network2 {
varible="dhcdbd"
s_demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
if [[ "$s_demon" == *$varible* ]]
then
old1="!$varible"
new1="$varible"
sed -i s/"$old1"/"$new1"/g /etc/rc.conf
old2="@$varible"
new2="$varible"
sed -i s/"$old2"/"$new2"/g /etc/rc.conf
old3="$varible"
new3="!$varible"
sed -i s/"$old3"/"$new3"/g /etc/rc.conf
fi
}
function s_network3 {
varible="networkmanager"
s_demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
if [[ "$s_demon" == *$varible* ]]
then
old1="!$varible"
new1="$varible"
sed -i s/"$old1"/"$new1"/g /etc/rc.conf
old2="@$varible"
new2="$varible"
sed -i s/"$old2"/"$new2"/g /etc/rc.conf
old3="$varible"
new3="!$varible"
sed -i s/"$old3"/"$new3"/g /etc/rc.conf
fi
}
# LAPTOP-MODE ==============================================================#F
function laptop_mode {
pacman -S --noconfirm laptop-mode-tools
demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
if [[ "$demon" != *laptop-mode* ]]
then
READ=$(cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")" )
WRITE="$demon @laptop-mode"
sed -i s/"$READ"/"$WRITE"/g /etc/rc.conf
echo -e "\e[1;33mLaptop-mode installed and configured\e[0m"
else
echo -e "\e[1;33mLaptop-mode installed.\e[0m"
fi
}
# CPUFREQ ==================================================================#F
function cpufreq {
pacman -S --noconfirm cpufrequtils
demon=`cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")"`
modul=`cat /etc/rc.conf | grep "MODULES=(" | tr -d "MODULES=(" | tr -d ")"`
visud=`cat /etc/sudoers`
if [[ "$demon" != *cpufreq* ]]
then
READ=$(cat /etc/rc.conf | grep "DAEMONS=(" | tr -d "DAEMONS=(" | tr -d ")" )
WRITE="$demon @cpufreq"
sed -i s/"$READ"/"$WRITE"/g /etc/rc.conf
echo -e "\e[1;33mDeamon for laptop-mode added\e[0m"
fi
if [[ "$modul" != *cpufreq* ]]
then
READ=$(cat /etc/rc.conf | grep "MODULES=(" | tr -d "MODULES=(" | tr -d ")" )
WRITE="$modul acpi-cpufreq cpufreq_powersave cpufreq_ondemand"
sed -i s/"$READ"/"$WRITE"/g /etc/rc.conf
echo -e "\e[1;33mModule for laptop-mode added\e[0m"
fi
if [[ "$visud" != *cpufreq* ]]
then
echo "ALL ALL=NOPASSWD:/etc/rc.d/cpufreq-set" >> /etc/sudoers
echo "ALL ALL=NOPASSWD:/etc/rc.d/cpufreq" >> /etc/sudoers
fi
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
echo "To use on demand governor use #sudo cpufreq-set -g ondemand" >> /home/$u_name/README
echo "To use powersave governor use #sudo cpufreq-set -g powersave" >> /home/$u_name/README
}
# VISUDO ===================================================================#F ############### NOT YET #############
function visudo {
echo "#%power ALL=(ALL) NOPASSWD: /usr/sbin/pm-hibernate" >> /etc/sudoers
}
# OPENBOX-MENU =============================================================#F
function openbox_menu {
pacman -Syu --noconfirm menumaker obconf
mmaker -vf OpenBox3
}
# OPENBOX-MENU =============================================================#F
function readme {
rm /home/$u_name/README
echo "# A script to automate installation and configuration of ArchLinux" >> /home/$u_name/README
echo "# Author: Jakadinho" >> /home/$u_name/README
echo "# v0.1.1" >> /home/$u_name/README
echo "# ======================================================================== #" >> /home/$u_name/README
}
function last {
#### AT THE END
rm /tmp/u_name
rm /tmp/user_ch
rm /tmp/archite
#Return ownership to the approtiate users
chown -R $u_name:users /home/$u_name/
chmod -R 750 /home/$u_name/.config/openbox
chmod -R 750 /home/$u_name/.config/README
echo -e "\e[1;31mALL DONE !!!!\e[0m"
echo -e "\e[1;33mRead /home/$u_name/README !!!!\e[0m"
exit
}
### START
q_update
q_user
readme
q_architecture
q_sudo
q_hal #+deamon
q_cpufreq #+deamon +module +visudo
q_network #+deamon
q_alsa #+deamon
q_laptop_mode #+deamon
#slim
q_yaourt
q_volwheel
q_bmpanel
q_xscreen
q_gamin
q_volume_manager
q_alsa
q_multimedia
q_recomended
q_internet
q_openbox_menu
last