LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 06-13-2004, 01:18 AM   #1
carmstrong
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:

Code:
#!/bin/bash
#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."
exit
 
Old 06-13-2004, 10:43 AM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
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.
 
  


Reply


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 02:12 PM
IPtables Script Review carmstrong Linux - Security 6 05-04-2004 01:55 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 01:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-06-2003 12:58 AM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 06:34 AM


All times are GMT -5. The time now is 10:27 AM.

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