Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 06-13-2004, 12:18 AM   #1
LQ Newbie
Registered: May 2004
Location: Pittsburgh, PA, USA
Distribution: Fedora Core 1
Posts: 19

Rep: Reputation: 0
bash script: Review please

Hey guys! I'd like to ask if anyone can spot any syntax errors by me in a bash script I wrote. The script is supposed to create a new user account for us. Here goes:

#parameters: user password sharename
echo "Create: $1" >> newuser.log
/usr/sbin/adduser --shell /bin/false $1 >> newuser.log
chpass() { [[ ! $2 ]] && return 1; { sleep 1; echo $2; sleep 1; echo $2; } passwd $1; }
chpass $1 $2
/bin/mkdir /home/custom/apache2/htdocs/$1 >> newuser.log
/bin/chmod -R 777 /home/custom/apache2/htdocs/$1 >> newuser.log
/bin/mkdir /home/ps/$1
/bin/cp /home/ps/master/* /home/ps/$1
/bin/chmod -R 777 /home/ps/$1
nuu=`cat /etc/passwd |grep $1 | awk -F: '{print $3}'`
/bin/mount --bind -t smbfs //w1/$3 /home/$1/hlds -o username=administrator,password=bah,uid=$nuu >> newuser.log
echo 'mount --bind -t smbfs //w1/$3 /home/$1/hlds -o username=administrator,password=bah,uid=$nuu' >> /etc/init.d/armstrong
/bin/mount --bind /home/$1/web /home/custom/apache2/htdocs/$1 -o uid=$nuu >> newuser.log
echo 'mount --bind /home/$1/web /home/custom/apache2/htdocs/$1 -o uid=$nuu' >> /etc/init.d/armstrong
/bin/mount --bind /home/$1/psychostats /home/ps/$1 -o uid=$nuu >> newuser.log
/home/custom/mysqld-4.0.20/bin/mysqladmin create $1
echo 'grant all on $1.* to $1@localhost identified by '$2';' > temp.sql
/home/custom/mysqld-4.0.20/bin/mysql -u root --password='bah' < ./temp.sql
echo 'mount --bind /home/$1/psychostats /home/ps/$1 -o uid=$nuu' >> /etc/init.d/armstrong
echo "All done! Type cat newuser.log to look for errors, as they've been removed from this output."
echo "Try to login via FTP and verify everything is working."
Old 06-13-2004, 09:43 AM   #2
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 235Reputation: 235Reputation: 235
Holy crap that is messy to read.. anyway you can edit and clean up, maybe add some spaces, space some of the lines, etc? But how do we know if there are any errors since it appears your mounting shares, etc? Have you tested it yourself, not like it would hurt anything if you did, easily just remove the test user, etc.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash - review assignments tarja Programming 4 11-24-2005 01:12 PM
IPtables Script Review carmstrong Linux - Security 6 05-04-2004 12:55 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 05:34 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:17 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration