See my own comment below:
I am trying to append a variable from an adduser script to a line in a config file (for samba).Can someone assist me here?The function is in BOLD below: createNewSambaAllow()It's not working to put the new line in the smb.conf file?Cry! Beg! Plead!Note: This is a assuming I already have a user named "unique" in my smb.conf line.#####################################start script#######################################3#!/bin/bash# Add shell and samba user._now=$(date +"%m_%d_%Y")basedir=/homeusershell=/bin/bash## Declare all the functions first## function to check if user already exists on systemifUserExits(){grep $1 /etc/passwd > /dev/null[ $? -eq 0 ] && return $TRUE || return $FALSE}## function to create the user with default shell and home directory passed from belowcreateNewUser(){if /usr/sbin/useradd "$@"then echo "User $6 Added"fi}## function to set the user passwordcreatePassword(){if echo -e "$1\n$1\n" | echo $1:$2 |chpasswdthen echo "Password Created for User $2"fi}## function to setup samba usercreateNewSambaUser(){if (echo $1; echo $1) | /usr/bin/smbpasswd -as $2then echo "Samba Account for User $2 Added"fi}#####This is the part I have issues with:## function to add user to the Samba config and restart daemoncreateNewSambaAllow(){# Copy to backup the config:cp /etc/samba/smb.conf /etc/samba/smb.conf-$_now# stuff the line we need to append to into a variable called $oldline# this is supposed to look like this "valid users = unique thing1 thing2 thing3 alice"oldline = grep unique /etc/samba/smb.conf# delete the old line in the smb.confsed '/unique/d' /etc/samba/smb.conf
sed -e 's/unique/ $username/' /etc/samba/smb.conf
# restart samba/etc/init.d/samba restartecho "Samba Config Added and Daemon restarted"}
### This is just for your info ####### make sure root is running scriptif [ $(id -u) -ne 0 ]thenecho "You must be root or use sudo to run this script!"exit 2fi## get username from inputread -p "Enter username : " username## if user doesn't exist, add userif ( ! ifUserExits $username )then## get password from inputread -p "Enter password : " passwordcreateNewUser -m -b $basedir -s $usershell $usernamecreatePassword $password $usernamecreateNewSambaUser $password $usernamecreateNewSambaAllow $usernameelse## oops, username already being usedecho "Username \"$username\" already exists"exit 3fi# End Bash Example--
Anyone?(503) 754-4452 Android
(623) 239-3392 Skype
(623) 688-3392 Google Voice
**
it-clowns.com
Chief Clown