LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Funtoo bash install script... (https://www.linuxquestions.org/questions/programming-9/funtoo-bash-install-script-706740/)

manwithaplan 02-23-2009 12:32 AM

Funtoo bash install script...
 
Hi all ... just wanna say that I'm somewhat a novice with bash and just need some pointers. This script isnt complete... but, its at a point where I can run it to certain point to test. I'm writing this to use with friends and myself for semi-automated install. I'm having a problem with line 67 - 79 (ITS IN BOLD). I want it to begin downloading by pressing the (1) key, and if there is any break in the script or problem I want it to exit. The output suggests a syntax error... Just cant find it...
Code:

#!/bin/bash
#Funtoo stage3 chroot Installation Script(x64 Core2 build)(2009-Beta)
#Installs from existing x64 distro
#Made by Manwithaplan
#Contact: manwithaplan@comcast.net

# You must have GPARTED installed & an active internet connection
# WARNING!!! Make sure you use the correct drive paths for SWAP, HOME, ROOT Or you'll overwrite your partitions

#Checks if user is root
if [ `id -u` != "0" ]; then
echo "Funtoo Installation Script 2009-beta-test script"
echo "Sorry, you are not root."
echo "Please restart script as root."
fi

#When user is , it gives information about the script
echo
echo "This script installs Funtoo 64bit core2 distro"
echo "Created by Manwithaplan"
echo "This is for Core2 (x64) machines only."
echo
echp
echo "Working internet connection is a must"
echo "And you must have gparted and wget installed"
echo
echo
echo "To continue press Enter..."
read key

#Gives user opportunity to check its partitions
echo "The script will launch gparted, for you to set up your partitions..."
echo "If set, just close gparted"
echo "Press Enter to continue"
read key
echo "Launching gparted..."
gparted

echo "It seems you've set your partitions, and you are ready to continue"
echo "Press Enter to continue"
read key

#Asks for boot, swap and home partition
echo "What is the boot partition of your Funtoo installation?"
echo "Example : /dev/sdb1"
read BOOTPART
echo "What is the Swap partition?"
read SWAP
echo "What is your Funtoo (home) partition?"
read FUNTOOHOME

#Activates Swap partition, mounts boot & home partition
mkswap $SWAP
swapon $SWAP

mkdir /mnt/funtoo
mount $FUNTOOHOME /mnt/funtoo
mkdir /mnt/funtoo/boot
mount $BOOTPART /mnt/funtoo/boot

#Downloading stage file
cd /mnt/funtoo
clear
echo "Now where going to download the stage3 file..."
echo "Downloading from http://www.funtoo.org/"
echo
echo
echo
echo "Press the (1) key to continue:"
read INSTALL

if [ $INSTALL -eq 1]
then
echo "Downloading Stage3 file..."
wget http://funtoo.org/linux/funtoo/~core2/stage3-~core2-current.tar.bz2
else
echo "You must not have a working internet connection, or wget isn't installed"
echo "Press any key to quit"
read key
exit
fi


#Unpacks Stage3 tar file
clear
echo
echo "Stage 3 file Downloaded"
echo "Press the Enter key to continue unpacking"
read key
echo "Unpacking Stage 3 file..."

tar xvjpf stage3-*.tar.bz2   

echo "Unpacked..."
echo "Now Mounting Filesytem"

#Copies DNS information
echo "Copying DNS information"
cp -L /etc/resolv.conf /mnt/funtoo/etc/resolv.conf

#Mounts Proc filesystem
echo "Mounting proc filesystem"
mount -t proc none /mnt/funtoo/proc

#Binds Dev directory
echo "Binding dev directory"
mount -o bind /dev /mnt/funtoo/dev

#Chroots into new Enviroment"
echo "Chrooting into Enviroment"
chroot /mnt/funtoo /bin/bash
env-update
source /etc/profile
export PS1="(chroot) $PS1"


#You are now chrooted, and partitons mounted on system...

#Time to Edit /etc/make.conf to and any CFLAGS etc...
echo "Press Enter to edit make.conf"
read key
nano /etc/make.conf
clear

# Downloading Funtoo portage
cd /
cd /etc/portage
echo "Now we need to download the latest Funtoo snapshot"
echo "Located @ http://www.funtoo.org/linux/funtoo/snapshots/"
echo "Please download the funtoo snapshot file to....  /usr/portage/"
echo
echo "For this we need to use your web client"
echo "Please choose which Browser want to use to download with"
echo
echo "Remember to save it in /etc/portage/"
echo
echo "Press (1) for firefox"
echo "Press (2) for epiphany"
echo "Press (3) for konqueror"
echo "Press (4) for opera"
echo "Press (5) for seamonkey"
echo
echo "Please enter (1-5) to continue:"
read DL

if [ $DL -eq 1 ]
then
echo "Launching firefox, Please close to continue"
firefox http://funtoo.org/linux/funtoo/snapshots/

elif [ $DL -eq 2 ]
then
echo "Launching epiphany, Please close to continue"
epiphany http://funtoo.org/linux/funtoo/snapshots/

elif [ $DL -eq 3 ]
then
echo "Launching konqueror, Please close to continue"
konqueror http://funtoo.org/linux/funtoo/snapshots/

elif [ $DL -eq 4 ]
then
echo "Launching opera, Please close to continue"
opera http://funtoo.org/linux/funtoo/snapshots/

elif [ $DL -eq 5 ]
then
echo "Launching seamonkey, Please close to continue"
seamonkey http://funtoo.org/linux/funtoo/snapshots/
else
echo "There must be a problem with your connection or browser"
echo
echo "Press any key to exit...."
exit

#Updates Portage Tree
#echo "Updating Portage tree"
#echo "Press any key to continue"
#read key
#echo
#cd /usr/portage
#script finished until here still working on finishing up with adding #some code to add meta packages for an X Desktop


Here's the output:
Quote:

./Auto_gentoo_build.sh: line 71: [: missing `]'
Any help would be great Thanks to anyone in advance



DISREGARD.... I WAS MISSING A SPACE IN THE BRACKETS ...........

TITiAN 02-23-2009 01:41 AM

ok then your problem is solved.
i'm posting in order to remove this from the "zero reply" list


All times are GMT -5. The time now is 10:52 PM.