Ubuntu Pastebin

Paste from ogra at Fri, 29 Apr 2016 15:42:56 +0000

Download as text
 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
ogra@anubis:~/datengrab/devel/branches/livecd-rootfs$ cat live-build/ubuntu-core/hooks/01-setup_user.chroot 
#!/bin/sh -x

set -e

USER=ubuntu
UGID=1000

echo "I: creating default user $USER"
adduser --gecos $USER --disabled-login $USER --uid $UGID

for extragroup in adm sudo; do
    adduser $USER $extragroup
done

chown -R $UGID:$UGID /home/$USER

# Enable libnss-extrusers
sed -i 's/^group:.*compat/\0 extrausers/' /etc/nsswitch.conf
sed -i 's/^passwd:.*compat/\0 extrausers/' /etc/nsswitch.conf
sed -i 's/^shadow:.*compat/\0 extrausers/' /etc/nsswitch.conf

# Move user from /etc to extrausers location
grep "^$USER" /etc/group >> /var/lib/extrausers/group
grep "^$USER" /etc/passwd >> /var/lib/extrausers/passwd
grep "^$USER" /etc/shadow >> /var/lib/extrausers/shadow
grep "^$USER" /etc/gshadow >> /var/lib/extrausers/gshadow
chmod 0644 /var/lib/extrausers/group
chmod 0644 /var/lib/extrausers/passwd
chmod 0640 /var/lib/extrausers/shadow
chmod 0640 /var/lib/extrausers/gshadow
chown root:shadow /var/lib/extrausers/shadow
chown root:shadow /var/lib/extrausers/gshadow
sed -i "/^$USER/d" /etc/group
sed -i "/^$USER/d" /etc/passwd
sed -i "/^$USER/d" /etc/shadow
sed -i "/^$USER/d" /etc/gshadow
touch /var/lib/extrausers/subuid
touch /var/lib/extrausers/subgid

# needs to run *after* the user was moved out to /var/lib/extrausers
echo "I: set user $USER password to $USER"
echo "$USER:$USER" | chpasswd
Download as text