summaryrefslogtreecommitdiff
path: root/tools/cloud-init/99-debug-user.chroot
blob: 354b46abf9c4107835b44d654d443d4989907aee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
# Script to add a user to Linux system
if [ $(id -u) -eq 0 ]; then
	egrep "^debuguser" /etc/passwd >/dev/null
	if [ $? -eq 0 ]; then
		echo "$username exists!"
		exit 1
	else
		pass=$(perl -e 'print crypt($ARGV[0], "password")' debuguser)
		useradd -m -p $pass debuguser
                usermod -aG sudo debuguser
		[ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
	fi
else
	echo "Only root may add a user to the system"
	exit 2
fi