-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.sh
34 lines (31 loc) · 954 Bytes
/
init.sh
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
#!/bin/bash
if [ -n "$EXTRA_PACKAGES" ] ; then
yum install -y $EXTRA_PACKAGES
fi
groupadd -g $USERGID engr
useradd -d $HOME -M -u $USERID -g $USERGID $USERNAME
echo "$USERNAME ALL=(ALL) NOPASSWD: ALL" | tee -a /etc/sudoers > /dev/null
sudo usermod -a -G mock $USERNAME
if [ -e "/var/run/docker.sock" ] ; then
DOCKERGROUP=$(stat -c "%g" /var/run/docker.sock)
if [ "$DOCKERGROUP" != "0" ] ; then
groupmod -g $DOCKERGROUP docker 2>/dev/null || groupadd -g $DOCKERGROUP docker
usermod -aG docker $USERNAME
fi
fi
echo "export MOCK_OPTS='--old-chroot'" >> /etc/bashrc
echo "export LANG='$LANG'" >> /etc/bashrc
echo
echo "Welcome to $RELEASE_DISTRO $RELEASE_VERSION builder"
echo
if [ -n "$SCRIPTRUNNER" ] ; then
if [ -d "$CURRENTPATH" ] ; then
cd $CURRENTPATH
else
cd $HOME
fi
chmod 755 $SCRIPTRUNNER
sudo --preserve-env="CURRENTPATH LANG" -u $USERNAME $SCRIPTRUNNER
else
su - $USERNAME
fi