-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup-kojiuser
executable file
·65 lines (54 loc) · 1.84 KB
/
setup-kojiuser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
echo "======================"
echo "=== setup-kojiuser ==="
echo "======================"
# The Fedora docs say to make these accounts without passwords but I think
# thats a terrible idea. For script purposes the passwords are defined here
# but can be reset to something a bit more secure afterwards
. `pwd`/defaults
# Check that all the externally defined variables we use in this script are initailized
echo -n "Checking the defaults of the following: "
for i in TOP KOJIPASS; do
if [ \$$i ]; then
echo -n "$i "
eval n=\$$i
if [ ! $n ]; then
echo
echo "conf error: $i is NOT defined/set in the defaults file. exiting."
exit 1
fi
fi
done
echo " (OK)"
TOPDIR=$TOP/koji
# ========================================================================
# No way around it, we gotta be root to do all this stuff
# ------------------------------------------------------------------------
#
if [ `id -u` != "0" ]; then
echo "Buzzt! sorry, you have to be root to run this script successfully"
exit 1
fi
# ========================================================================
# Make sure Koji (or whatever) exists
# ------------------------------------------------------------------------
#
if [ ! -d $TOPDIR ] ; then
mkdir -p $TOPDIR
fi
getent passwd koji > /dev/null 2>&1
RESULT="$?"
if [ "${RESULT}" == "0" ] ; then
echo "koji user ID already created as system user - skipping user koji creation"
TOPDIR=`getent passwd koji | cut -f 6 -d":"`
if [ ! -d $TOPDIR ] ; then
mkdir -p $TOPDIR
fi
else
echo "System has NOT got user ID koji - creating user koji with the homedir as $TOPDIR"
mkdir -p $TOPDIR
useradd koji -d $TOPDIR
echo $KOJIPASS | passwd --stdin koji
fi
echo "Don't forget to set the koji password to something"
echo "a little more secure afterwards"