Guest uploader setup script

Just slammed together a script to add users and give them access to the “upload” user directory.

Edit: Sorry for the updates, it turned out the first version was not optimal.


# Usage: uploader [username ...]

	test -t 1 && {
		tput setf 4
		echo "$1" >&2
		tput setf 7
	} || echo "$1" >&2
	exit 1

users="upload $*"

for user in $users
	# Create user if necessary
	id $user 1>/dev/null 2>&1
	if [ "$?" -ne "0" ]
		useradd --groups upload --comment "Upload user" $user && \
		echo "Created upload user '${user}'." || \
		error "Could not create upload user '${user}'."

# Disable upload password
usermod --lock upload

# Files
chown -R upload:upload ~upload || \
error "Could not change owner of upload home dir"
chmod -R ug+rwX,o= ~upload || \
error "Could not change rights of upload home dir"

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s