You are not logged in.
Pages: 1
I'm writing a bash script to install all the necessary stuff in stage two of the installation. Its cool to do it all manually the first time you install arch since you learn alot, but after that it just becomes annoying and time consuming, so I got bored one night and decided to code a script to remedy this problem.
I managed to kill all the previous bugs that have come up, but two leave me confused:
1) if i reference the pacman mirrorlist in pacman.conf, pacman acts as if it cant connect to the server, but if i place a mirror in pacman.conf and decide not to use the mirrorlist everything works fine.
heres my pacman.conf:
#
# /etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives
#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
# If you wish to use different paths, uncomment and update the paths.
#RootDir = /
#DBPath = /var/lib/pacman/
#CacheDir = /var/cache/pacman/pkg/
#LogFile = /var/log/pacman.log
HoldPkg = pacman glibc
# If upgrades are available for these packages they will be asked for first
SyncFirst = pacman
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
#XferCommand = /usr/bin/curl %u > %o
#CleanMethod = KeepInstalled
# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
#IgnorePkg =
#IgnoreGroup =
#NoUpgrade =
#NoExtract =
# Misc options (all disabled by default)
NoPassiveFtp
#UseSyslog
#ShowSize
#UseDelta
#TotalDownload
#[testing]
#Include = /etc/pacman.d/mirrorlist
[core]
Include = /etc/pacman.d/mirrorlist
[extra]
Include = /etc/pacman.d/mirrorlist
[community]
Include = /etc/pacman.d/mirrorlist
[kdemod-legacy]
Server = http://kdemod.ath.cx/repo/legacy/x86_64
and heres my mirrorlist
#
# Arch Linux repository mirrorlist
#
# North America
# - United States
Server = ftp://ftp.archlinux.org/$repo/os/x86_64
Server = ftp://locke.suu.edu/linux/dist/archlinux/$repo/os/x86_64
Server = http://archlinux.unixheads.org/$repo/os/x86_64
Server = ftp://ftp.gtlib.gatech.edu/pub/linux/distributions/archlinux/$repo/os/x86_64
Server = ftp://mirror.cs.vt.edu/pub/ArchLinux/$repo/os/x86_64
Server = http://mirrors.easynews.com/linux/archlinux/$repo/os/x86_64
Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/$repo/os/x86_64
Server = http://archlinux.umflint.edu/mirrors/archlinux/$repo/os/x86_64
Server = http://mirror.neotuli.net/arch/$repo/os/x86_64
Server = http://mirror.rit.edu/archlinux/$repo/os/x86_64
Server = http://mirror.umoss.org/archlinux/$repo/os/x86_64
Server = http://schlunix.org/archlinux/$repo/os/x86_64
Server = http://mirror.archlinux.com.ve/$repo/os/x86_64
Server = http://mirrors.gigenet.com/archlinux/$repo/os/x86_64
2) To clean the output up when the script is running i have all the pacman output redirected to text files for each time pacman is called. The first instance of this redirection never seems to work correctly, yet each successive one works perfectly.
This is the first time that pacman is called, and the error is always 'bash: logs/install.python: No such file or directory' even though the directory logs does exist.
pacman -S --noconfirm python > logs/install.python
can someone please tell me whats wrong?
Offline
I think that the problem is that you are not installing but re-directing the output.
Here is a script I wrote to to the same thing you are doing and it works fine. Perhaps will help you :
#!/bin/bash
user=$UID
if [ $user != 0 ]
then
echo "Sorry. Only ROOT can run this program !"
exit
else
echo "###############( Updating Programs )###############"
echo
echo "Start: "
date
fi
# Basic programs
function baseprogs(){
echo "==============( Basic Programs )================="
echo
for PROGRAM in xorg-server xorg-xkb-utils xorg-xauth xorg-server-utils xorg-xinit xf86-video xf86-video-vesa xf86-input-mouse xf86-input-keyboard xorg-apps cups kde firestarter
do
echo +=========================+
echo "PROGRAM: $PROGRAM"
echo +=========================+
echo
pacman -Sy --noconfirm $PROGRAM
echo -e \\n\\n
done
}
# Productivity tools
function productivity(){
echo "==============( Productivity Programs )================="
echo
for PROGRAM in libdvdcss k3b gaim htop screen gkrellm gkrellmlaunch gkrellweather hwd openssh ntp host mc yakuake ethtool tuxcards
do
echo +=========================+
echo "PROGRAM: $PROGRAM"
echo +=========================+
echo
pacman -Sy --noconfirm $PROGRAM
echo -e \\n\\n
done
}
# Web Development
function webdev(){
echo "==============( Web Development Programs )================="
echo
for PROGRAM in bluefish cssed kdewebdev apache mod_python python-docs ipython mysql mysql-python mysqlcc mysql-gui-tools php
do
echo +=========================+
echo "PROGRAM: $PROGRAM"
echo +=========================+
echo
pacman -Sy --noconfirm $PROGRAM
echo -e \\n\\n
done
}
# Multimedia
function multimedia(){
echo "==============( Multimedia Programs )================="
echo
for PROGRAM in 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 xbindkeys
do
echo +=========================+
echo "PROGRAM: $PROGRAM"
echo +=========================+
echo
pacman -Sy --noconfirm $PROGRAM
echo -e \\n\\n
done
}
# Office productivity programs
function office(){
echo "==============( Office Programs )================="
echo
for PROGRAM in jre openoffice-base openoffice-spell-en openoffice-es
do
echo +=========================+
echo "PROGRAM: $PROGRAM"
echo +=========================+
echo
pacman -Sy --noconfirm $PROGRAM
echo -e \\n\\n
done
}
# MS-True Type fonts
function ttfonts(){
echo +=========================+
echo "Program: MS-TT Fonts"
echo +=========================+
echo
pacman -Sy --noconfirm ttf-ms-fonts echo -e \\n\\n
}
baseprogs
productivity
multimedia
office
ttfonts
webdev
echo "All done!"
R.
Offline
I was wondering this while coding if there is a way to redirect the output and execute it at the same time?
Offline
yes, you can use && to indicate concatenation of actions. The second will occur if the first is processed.
To use your own code in an example:
pacman -S --noconfirm python && logs/install.python
Hope this helps.
R.
Offline
There's nothing wrong in principle with
pacman -S --noconfirm python > logs/install.python
What this does is execute the pacman command and redirecting STDOUT (the text output) to the specified file.
The pacman command should run without problems.
Maybe you could post the script, so we can all have a look if you didn't err somewhere else?
---
pacman -S --noconfirm python && logs/install.python
^ This ^ won't work unless you have an executable file (script or some such) called "install.python" in the logs directory. If that is the case, it would get executed after successfull ending of the pacman command, which is not what you want i think...
pacman -S --noconfirm python | tee logs/python.install
^ This ^ allows you to both see the pacman output on screen and log it in you logfile
pacman -S --noconfirm python &> logs/install.python
^ This ^ allows you to redirect both STDOUT and STDERR to log/install.python
Hope this helps
Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!
Offline
Thanks everyone for the info. I didnt think that there was anything wrong with the way I was redirecting the output since the stuff I had installed (such as the xserver) runs without a problem. heres the full source code:
#! /bin/bash
mkdir logs
echo "Which interface are you using?"
read interface
dhcpcd $interface
echo
echo "Do you want to speed test the mirrors?"
echo "1) Yes"
echo "2) No"
read mirrors
if [[ "$mirrors" == 1 ]]; then
cp mirrorlist /etc/pacman.d/mirrorlist.bak
cd /etc/pacman.d
rm mirrorlist
pacman -S --noconfirm python > logs/install.python
echo
echo "Ranking mirrors, this could take a few minutes..."
rankmirrors -n 6 mirrorlist.bak > mirrorlist
cd /media/home/bubba/install.arch
fi
#copying pacman.conf with kdemod repositories
echo
echo "::Updating pacman and the system..."
pacman -Syy --noconfirm pacman > logs/update.pacman
pacman -Syu --noconfirm > update.system
cp -f pacman.conf /etc/pacman.conf
pacman -Syy > logs/pkg.refresh
echo
echo "::Installing NTFS-3g..."
pacman -S --noconfirm ntfs-3g > logs/install.ntfs3g
echo
read -p "Edit fstab to correspond to the current partition layout (Hit Enter)"
nano fstab
clear
cp fstab /etc/fstab
mkdir /media/w7; mkdir /media/xp; mkdir /media/media;mkdir /media/mybook; mkdir /media/mint
mount -a
#adding users and groups
echo
echo "Name your user:"
read user
useradd -m -G users,audio,lp,optical,storage,video,wheel,power -s /bin/bash $user
passwd $user
pacman -S --noconfirm sudo > logs/install.sudo
echo
read -p "Add this line to the sudoers file: "$user" ALL=(ALL) ALL"
EDITOR=nano visudo
clear
#necessary daemons already added to the array
cp -f rc.conf /etc/rc.conf
#configuring ALSA
echo
echo "::Installing ALSA..."
pacman -S --noconfirm alsa-utils alsa-oss > logs/install.alsa
cp -f asound.state /etc/asound.state
#installing the Xserver
echo
echo "::Installing the Xserver..."
pacman -S --noconfirm xorg xf86-input-evdev mesa nvidia > logs/install.xserver
cp -f xorg.conf /etc/X11/xorg.conf
depmod -a
#other stuff
/usr/sbin/groupadd -g 81 dbus
/usr/sbin/useradd -c 'System Message Bus' -u 81 -g dbus -d '/' -s /bin/false dbus
#setting login manager
#unnecessary if I add to login manager to daemon array?
#cp xinitrc /home/$user/.xinitrc
#installing common fonts
echo
echo "::Installing commonly used fonts..."
pacman -S --noconfirm ttf-ms-fonts ttf-dejavu ttf-bitstream-vera > logs/install.fonts
echo
echo "Install KDEmod 3 or KDEmod 4?"
echo "1) KDEmod 3"
echo "2) KDEmod 4"
read decision
if [[ "$decision" == 1 ]]; then
echo
echo "::Installing KDEmod 3..."
pacman -S --noconfirm kdemod3 > logs/install.kdemod3
cp -f locale.gen /etc/locale.gen
locale-gen
fi
if [[ "$decision" == 2 ]]; then
cp -f pacman.conf_kdemod4 /etc/pacman.conf
echo
echo "::Installing KDEmod 4..."
pacman -S --noconfirm kdemod > logs/install.kdemod4
cp -f locale.gen /etc/locale.gen
locale-gen
fi
/etc/rc.d/hal start
#installing other stuff
echo
echo "::Installing firefox, thunderbird, yakuake, etc..."
pacman -S --noconfirm firefox thunderbird libdvdcss yakuake compiz-fusion-plugins-main compiz-fusion-plugins-extra fusion-icon ktorrent pidgin jre shaman samba kdemod3-kdeutils-superkaramba lm_sensors > logs/install.otherstuff
#customizing
cp bashrc /home/$user/.bashrc
cp -f Desktop /home/$user/Desktop
cp -Rf emerald /home/$user/.emerald
echo
ln -s /media/w7/Users/Bran/AppData/Roaming/Firefox /home/$user/.firefox
ln -s /media/w7/Users/Bran/AppData/Roaming/Thunderbird /home/$user/.thunderbird
#copies Autostart to the correct kde folder
if [[ "$decision" == 1 ]]; then
cp -Rf Autostart /home/$user/.kde/
fi
if [[ "$decision" == 2 ]]; then
cp -Rf Autostart /home/$user/.kde4/
fi
startx
Offline
rm mirrorlist
pacman -S --noconfirm python > logs/install.python
There's your problem... Right before you pacman -S python, you remove mirrorlist... Therefore pacman cannot find the mirrorlist file and all kinds of breakage ensues
best try this instead:
pacman -S --noconfirm python > logs/install.python
rm mirrorlist
Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!
Offline
D'oh! (smacks forehead) good catch buddy....
Offline
how can i grab file locations and feed them into a variable? for example if i want to grab the profile names of my windows firefox and thunderbird and link it in my home directory, something along the lines of this:
cd /media/w7/Users/Bran/AppData/Roaming/Firefox
ls > profile
cat profile (into a variable some how)
ln -s /media/w7/Users/Bran/AppData/Roaming/Firefox/$profile /home/bran/.firefox
or if i want to assign the location of where the script is being ran from to the variable 'location'? ive tried location='pwd' and it works if i type $location at the bash prompt but if i type cd $location it says bash: cd: pwd: No such file or directory
Last edited by brando56894 (2009-03-03 02:40:47)
Offline
Close........... try this instead.
Not this:
location='pwd'
But THIS:
location=`pwd`
Offline
I didnt see it at first what is the difference between `` and '' ?
Last edited by brando56894 (2009-03-04 00:28:51)
Offline
Read it again. Perhaps use a larger font?
Edit: I see you got it. The backticks are used for substitution, basically.
Last edited by SamC (2009-03-04 00:29:37)
Offline
oh ok, thanks.
Offline
theres something wrong with the kde 4 portion of this if statement and i cant figure out what
echo
echo "Install KDEmod 3 or KDEmod 4?"
echo "1) KDEmod 3"
echo "2) KDEmod 4"
read decision
if [[ "$decision" == 1 ]]; then
echo
echo "::Installing KDEmod 3..."
cp -f pacman.conf_kdemod3 /etc/pacman.conf
pacman -Syy --noconfirm kdemod3 kdemod3-kdeutils-superkaramba > logs/install.kdemod3
cp -f locale.gen /etc/locale.gen
locale-gen > /dev/null
cp -f rc.conf_kdemod3 /etc/rc.conf
cp -Rf Autostart /home/$user/.kde/
else
echo
echo "::Installing KDEmod 4..."
cp -f pacman.conf_kdemod4 /etc/pacman.conf
pacman -Syy > logs/pkg.update
pacman -S --noconfirm kdemod kdemod-kdeutils-superkaramba > logs/install.kdemod4
cp -f locale.gen /etc/locale.gen
locale-gen > /dev/null
cp -f rc.conf_kdemod4 /etc/rc.conf
cp -Rf Autostart /home/$user/.kde4/
fi
it runs correctly but at the very end (after cp -Rf Autostart /home/$user/.kde4/) it will say something along the lines of "fi command not found". when i open it up in a GUI text editor that has syntax highlighting it doesnt even show up as an if statement.
Offline
function install_kde {
echo "::Installing KDEmod $1..."
cp -f "pacman.conf_kdemod$1" /etc/pacman.conf
pacman -Syy --noconfirm kdemod$1 kdemod$1-kdeutils-superkaramba > logs/install.kdemod$1
cp -f locale.gen /etc/locale.gen
locale-gen > /dev/null
cp -f rc.conf_kdemod$1 /etc/rc.conf
cp -Rf Autostart /home/$user/.kde$([[ "$1" == '4' ]] && echo '4')/
}
read -p "
Install KDEmod 3 or KDEmod 4?
1) KDEmod 3
2) KDEmod 4
*) Quit
> " decision
[[ "$decision" == '1' ]] && install_kde 3
[[ "$decision" == '2' ]] && install_kde 4
Last edited by Wintervenom (2009-03-08 05:02:31)
Offline
thanks but all i needed to do was put "then" on its own line and that fixed it
Offline
Pages: 1