Find the answer to your Linux question:
Results 1 to 6 of 6
Hey I wrote a Bash Script to make someone who never used linux to Configure the system without any problems. But, well i tested it and now I get Time ...
  1. #1
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422

    Bash Script Messed up my linux I guess

    Hey I wrote a Bash Script to make someone who never used linux to Configure the system without any problems.
    But, well i tested it and now I get Time Errors during boot and I know Ive made a mistake in the if trigger. (And I cant fix it)

    Can anyone take a look at my script and give me some Advice on it?

    Oh, btw the Echo stuff is all in Dutch..

    Sorry about that..

    Code:
    #! bin/bash (Ja, het is een BashScript.. :|)
    
    #SHOWELCOME
    clear #Eert maken we even Schoon
    #Ik weet dat dit makelijker kan met
    #cat bannner
    #But I dont give a Damn =)
    echo \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
    echo \#\#\#\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \#\#\#
    echo \#\#\#\ \ \Virtual\ Office\ Automatic\ Configuration\ \ \#\#\#
    echo \#\#\#\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \#\#\#
    echo \#\#\#\ \ \ \ \Welcome\ in\ de\ TextBased Configer\ \ \ \ \ \ \#\#\#
    echo \#\#\#\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \#\#\#
    echo \#\#\#\ \ \ \ \ Dit\ helpt\ u\ stap\ voor\ stap\ om\ \ \ \ \ \ \ \ \#\#\#
    echo \#\#\#\ \ \Dit\ systeem\ klaar\ temaken\ voor gebruik\.\ \#\#\#
    echo \#\#\#\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \#\#\#
    echo \#\#\#\ \ \ \ \ \ \ \ \ Druk\ een\ Knop\ om\ te\ beginnen\. \ \ \ \#\#\#
    echo \#\#\#\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \#\#\#
    echo \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
    read
    
    #SHOWWHATSINTHERE
    echo Dit zit er in de PCI-e Sloten.
    echo Vaak slim om opteschrijven ergens want dit heb je later nodig
    lspci
    echo Druk een knop om verder te gaan
    read
    
    #TIME AND DATE
    echo We gaan eerst de Tijd Goed Insellen
    echo Het formaat is:
    echo MMDDhhmmYYYY
    echo Dus met 1 Maart 2003 4:50 krijgen we
    echo 020104502003
    echo Als de datum && date && echo is druk gewoon op Enter
    echo Geef datum in:
    read DATE
    date $DATE
    
    #TIMEZONE
    echo Timezone gaan we instellen
    echo Druk een knop om verder te gaan
    read
    nano -w /etc/conf.d/clock
    
    #NETWORK SETUP
    echo Nu gaan we het netwerk instellen
    ifconfig
    echo Host Naam \= 
    hostname
    echo DNS Domein Naam \= 
    dnsdomainname
    echo Klopt dit? \(j\/n\)
    read YESNO
    if "$YESNO" = "$NO"; then
      nano -w /etc/conf.d/net
    fi
    
    #OTHER CONFIG
    echo en nu komen er nog wat configfiles
    echo druk een Knop om verder te gaan.
    read
    nano -w /etc/conf.d/rc
    nano -w /etc/conf.d/keymaps
    nano -w /etc/make.conf
    
    #KERNEL
    echo Nu word de Kernel gemaakt.
    echo Let Goed op dat de volgende dingen AANSTAAN!
    echo File systems \-\-\> 
    echo  \[\*\] Qouta support
    echo  \<M\> Qouta format v2 support
    echo Zorg dat het ext2 \+ ext3 Filesystem aanstaat.
    echo Druk op een knop om verder te gaan.
    read
    mount /dev/hdd1
    cd /usr/src/linux
    make menuconfig
    make&&make modules_install
    mv /boot/kernel-2.6 /boot/kernel-2.6.backup
    cp arch/i386/boot/bzImage /boot/kernel-2.6
    
    #PASSWORD
    echo Er moet een Sterk root Password gekozen worden.
    echo Zorg dat het wachtwoord minimaal\:
    echo \ \ \-\ 7 Tekens is
    echo \ \ \-\ 2 Cijfers er in heeft die niet naast elkaar staan
    echo \ \ \-\ 1 Raar teken
    echo \ \ \-\ NERGENS opgeschreven word.
    echo
    echo Een mooi voorbeeld van een SterkWachtwoord dat aardig makelijk te onthouden is
    echo 1mvBv1sWWd\@mtoi
    echo Dat is de zin daarboven in een wachtwoord formaat.
    echo Geef nu uw nieuwe wachtwoord in.
    passwd
    
    #EMERGE
    echo Voer de alle namen in van alle extra software die geinstalleerd gaat worden.
    read EMERGE
    emerge -av $EMERGE
    
    #CLOSE THIS ALL
    clear
    cowsay NU hopen we dat het systeem werkt.
    echo Druk een knop om het Systeem opnieuw optestarten.
    read
    cowsay -f dragon-and-cow REBOOT!!
    sleep 1
    reboot
    New Users, please read this..
    Google first, then ask..

  2. #2
    Just Joined!
    Join Date
    Aug 2007
    Posts
    37
    Quote Originally Posted by RobinVossen View Post
    ...I know Ive made a mistake in the if trigger. (And I cant fix it)...
    "$NO" is undefined. Try this:
    Code:
    echo "Klopt dit? (j/n)"
    read -s YESNO
    if [ "$YESNO" == "n" ]; then
      nano -w /etc/conf.d/net
    fi
    By the way, you don't need all those back-slashes "\" in the banner, just use single quotes to protect your text:

    Code:
    echo '################################################'
    echo '###                                          ###'
    echo '###  Virtual Office Automatic Configuration  ###'
    echo '###                                          ###'
    echo '###    Welcome in de TextBased Configer      ###'
    echo '###                                          ###'
    echo '###     Dit helpt u stap voor stap om        ###'
    echo '###  Dit systeem klaar temaken voor gebruik. ###'
    echo '###                                          ###'
    echo '###         Druk een Knop om te beginnen.    ###'
    echo '###                                          ###'
    echo '################################################'

  3. #3
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    Quote Originally Posted by jozyba View Post

    By the way, you don't need all those back-slashes "\" in the banner, just use single quotes to protect your text:
    I know ive put that in there as Dutch Commentary.
    But I was bored and I had to fill up time.. ^^

    Thats for the Help ^^
    New Users, please read this..
    Google first, then ask..

  4. #4
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Your shebang line needs a slash not a space after the #!.
    And I'm not sure that extra text on the shebang line is A Good Idea, either.

  5. #5
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    Its commentary that bin/bash is just for the editors of the scripts so they know what kinda script it is.. :/
    New Users, please read this..
    Google first, then ask..

  6. #6
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Quote Originally Posted by RobinVossen View Post
    Its commentary that bin/bash is just for the editors of the scripts so they know what kinda script it is.. :/
    Then you should put it on the next line as a comment, otherwise the kernel may well try to execute it, or at least pass it as arguments to bash. #! in the first two bytes of an executable text file is a special character pair to the kernel.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...