Skip to content

Commit c8b534f

Browse files
committed
Give the mysql user suitable group membership. Give the developer sudo rights.
- Legacy-Id: 10483
1 parent e72cdf4 commit c8b534f

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

docker/docker-init.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ if [ ! -d $MYSQLDIR/mysql ]; then
1616
echo "WARNING: Expected the directory $MYSQLDIR/mysql/ to exist -- have you downloaded and unpacked the IETF binary database tarball?"
1717
fi
1818

19+
echo "Setting up the 'mysql' user for database file access ..."
20+
MYSQL_TARGET_GID=$(stat -c "%g" $MYSQLDIR/mysql)
21+
if ! grep -q ":$MYSQL_TARGET_GID:$" /etc/group; then
22+
groupadd -g $MYSQL_TARGET_GID mysqldata
23+
fi
24+
usermod -a -G $MYSQL_TARGET_GID mysql
25+
1926
echo "Checking if MySQL is running ..."
2027
if ! /etc/init.d/mysql status; then
2128
echo "Starting mysql ..."
@@ -54,7 +61,8 @@ fi
5461

5562
if ! id -u "$USER" &> /dev/null; then
5663
echo "Creating user '$USER' ..."
57-
useradd -s /bin/bash -G staff $USER
64+
useradd -s /bin/bash -G staff,sudo $USER
65+
echo "$USER:$USER" | chpasswd
5866
fi
5967

6068
VIRTDIR="/opt/home/$USER/$TAG"

0 commit comments

Comments
 (0)