sea
13th January 2012, 02:33 PM
Heyas
I'm currently rewriting an installation script, which, start to confuse me pretty much.
1) The script asks for whom to install (all or $(whoami)) and sets the target dir to either: /opt/sc or $HOME/sc. (working)
2) It ask if you either prefer GIT or WGET the files from SF.net (working)
3) It tries to add variables to either /etc/bashrc or $HOME/.bashrc, depending on the 'target user'.. (fail: cat, grep not found ??)
4) And finaly it calls up the script, which produces similar errors, many, actualy no commands are found :(
The git version is NOT ment to be working at this time!, however, the errors result as well with the tarball one wget.
Anyone got an idea what causes such an issue?
#!/bin/bash
# | This script is written for sc-0.1.2-all.tar.bz2, to
# be installed in a Fedora enviroment.
# | sc-0.1.2 is NOT released yet!!
# | This scripts expects to be run as $USER beeing in sudoers.
# | sudo chmod +x sc-install.sh
# ----------------------------------------------------------
# |
# | Variables
modules="lfs set sup"
# COLORS
esc="" ; whitef="${esc}[37m"; blueb="${esc}[44m"; reset="${esc}[0m"
seacolor=${whitef}${blueb}
# Tarball naming structure
tarball="sc-?.?.?-all.tar.bz2"
tmpfile=/tmp/sc-inst.swp
# USER CHOICE
defaultdir="$HOME/sc" ; defaultbash="$HOME/.bashrc"
alldir="/opt/sc" ; allbash="/etc/bashrc"
# |
# | Clean & Logo
clear
cat > /tmp/seaLogo << EOF
${seacolor}╔══════════════════════╗${reset}
${seacolor}║ ║${reset}
${seacolor}║ ╔══╗ ╔═══╗ ╔═══╗ ║${reset}
${seacolor}║ ║ ║ ║ ║ ║${reset}
${seacolor}║ ╚══╗ ╠═══╝ ╔═══╣ ║${reset}
${seacolor}║ ║ ║ ║ ║ ║${reset}
${seacolor}║ ╚══╝ ╚═══╝ ╚═══╝ ║${reset}
${seacolor}║ ║${reset}
${seacolor}╚══════════════════════╝${reset}
EOF
while read line ; do printf "\n\t\t$line" ; done < /tmp/seaLogo && printf "\n::\tLinux Scripts reloaded since 25th May 2011\t::\n"
# |
# | Destination
all="To all on this device."
echo
echo ":: Please choose for which user/s you want to install the script collection."
select target in "$all" $(whoami) ; do
if [[ "$target" = "$all" ]]
then if [[ 0 = $UID ]] ; then
targetdir=$alldir
targetbash=$allbash
else
echo "Need to reload the script with root rights."
su -c "$0 $1" && break
fi
else targetdir=$defaultdir
targetbash=$defaultdir
fi
break
done && echo
# |
# | Source
echo
aA="GIT the script files from Sourceforge.net"
bB="WGET Download latest tarball from SF.net"
echo ":: Please choose your prefered retrieve method."
select target in "$aA" "$bB" ; do
if [[ "$target" = "$aA" ]]
then git clone git://git.code.sf.net/p/seasc/core/sc-core $targetdir
for e in $modules ; do
git clone git://git.code.sf.net/p/seasc/sc-$e/sc-$e $targetdir/collection/$e
done
else mkdir -p $targetdir ; cd $targetdir
wget -nc https://sourceforge.net/projects/seasc/files/latest/download
tar -axf $tarball
fi
break
done
# |
# | Include it to current enviroment
echo
echo ":: Adding variables to $targetbash..."
scDir=$targetdir
pathadd="\$PATH:$scDir:$scDir/collection"
PATH=$pathadd
export PATH scDir
echo ":: Writing \"$scDir\" and \"$PATH\" to \"$targetbash\"..."
cat > $tmpfile << EOF
# | SC settings : start"
PATH=$pathadd"
source $scDir/sc.cfg"
export PATH scDir"
# | SC settings : end"
EOF
cat $tmpfile >> $targetbash
# |
# | Finish installation
$scDir/sc readme && echo ":: Installation successfull."
Thanks for every hint, thought or solution in advance.
I'm currently rewriting an installation script, which, start to confuse me pretty much.
1) The script asks for whom to install (all or $(whoami)) and sets the target dir to either: /opt/sc or $HOME/sc. (working)
2) It ask if you either prefer GIT or WGET the files from SF.net (working)
3) It tries to add variables to either /etc/bashrc or $HOME/.bashrc, depending on the 'target user'.. (fail: cat, grep not found ??)
4) And finaly it calls up the script, which produces similar errors, many, actualy no commands are found :(
The git version is NOT ment to be working at this time!, however, the errors result as well with the tarball one wget.
Anyone got an idea what causes such an issue?
#!/bin/bash
# | This script is written for sc-0.1.2-all.tar.bz2, to
# be installed in a Fedora enviroment.
# | sc-0.1.2 is NOT released yet!!
# | This scripts expects to be run as $USER beeing in sudoers.
# | sudo chmod +x sc-install.sh
# ----------------------------------------------------------
# |
# | Variables
modules="lfs set sup"
# COLORS
esc="" ; whitef="${esc}[37m"; blueb="${esc}[44m"; reset="${esc}[0m"
seacolor=${whitef}${blueb}
# Tarball naming structure
tarball="sc-?.?.?-all.tar.bz2"
tmpfile=/tmp/sc-inst.swp
# USER CHOICE
defaultdir="$HOME/sc" ; defaultbash="$HOME/.bashrc"
alldir="/opt/sc" ; allbash="/etc/bashrc"
# |
# | Clean & Logo
clear
cat > /tmp/seaLogo << EOF
${seacolor}╔══════════════════════╗${reset}
${seacolor}║ ║${reset}
${seacolor}║ ╔══╗ ╔═══╗ ╔═══╗ ║${reset}
${seacolor}║ ║ ║ ║ ║ ║${reset}
${seacolor}║ ╚══╗ ╠═══╝ ╔═══╣ ║${reset}
${seacolor}║ ║ ║ ║ ║ ║${reset}
${seacolor}║ ╚══╝ ╚═══╝ ╚═══╝ ║${reset}
${seacolor}║ ║${reset}
${seacolor}╚══════════════════════╝${reset}
EOF
while read line ; do printf "\n\t\t$line" ; done < /tmp/seaLogo && printf "\n::\tLinux Scripts reloaded since 25th May 2011\t::\n"
# |
# | Destination
all="To all on this device."
echo
echo ":: Please choose for which user/s you want to install the script collection."
select target in "$all" $(whoami) ; do
if [[ "$target" = "$all" ]]
then if [[ 0 = $UID ]] ; then
targetdir=$alldir
targetbash=$allbash
else
echo "Need to reload the script with root rights."
su -c "$0 $1" && break
fi
else targetdir=$defaultdir
targetbash=$defaultdir
fi
break
done && echo
# |
# | Source
echo
aA="GIT the script files from Sourceforge.net"
bB="WGET Download latest tarball from SF.net"
echo ":: Please choose your prefered retrieve method."
select target in "$aA" "$bB" ; do
if [[ "$target" = "$aA" ]]
then git clone git://git.code.sf.net/p/seasc/core/sc-core $targetdir
for e in $modules ; do
git clone git://git.code.sf.net/p/seasc/sc-$e/sc-$e $targetdir/collection/$e
done
else mkdir -p $targetdir ; cd $targetdir
wget -nc https://sourceforge.net/projects/seasc/files/latest/download
tar -axf $tarball
fi
break
done
# |
# | Include it to current enviroment
echo
echo ":: Adding variables to $targetbash..."
scDir=$targetdir
pathadd="\$PATH:$scDir:$scDir/collection"
PATH=$pathadd
export PATH scDir
echo ":: Writing \"$scDir\" and \"$PATH\" to \"$targetbash\"..."
cat > $tmpfile << EOF
# | SC settings : start"
PATH=$pathadd"
source $scDir/sc.cfg"
export PATH scDir"
# | SC settings : end"
EOF
cat $tmpfile >> $targetbash
# |
# | Finish installation
$scDir/sc readme && echo ":: Installation successfull."
Thanks for every hint, thought or solution in advance.