docker-debian-repository/scripts/start.sh

41 lines
937 B
Bash
Raw Normal View History

2014-08-12 21:04:26 +00:00
#!/bin/sh
# Many thanks to John Fink <john.fink@gmail.com> for the
# inspiration and to his great work on docker-wordpress'
2014-08-13 08:52:22 +00:00
# reset root password
2014-08-12 22:34:00 +00:00
# let's create a user to SSH into
2014-08-12 21:04:26 +00:00
SSH_USERPASS=`pwgen -c -n -1 8`
mkdir /home/user
2014-08-13 08:52:22 +00:00
useradd -G sudo -d /home/user -s /bin/bash user
2014-08-13 11:28:11 +00:00
chown -R user /home/user
chown -R user /docker/incoming
2014-08-12 22:34:00 +00:00
echo "user:$SSH_USERPASS" | chpasswd
echo "ssh user password: $SSH_USERPASS"
2014-08-13 08:52:22 +00:00
# pre-fill with SSH keys
echo "Pre-loading SSH keys from /docker/keys"
mkdir -p /home/user/.ssh
rm -f /home/user/.ssh/authorized_keys
for key in /docker/keys/*.pub ; do
echo "- adding key $key"
cat $key >> /home/user/.ssh/authorized_keys
done
chown -R user /home/user/.ssh
# load cron
2014-08-12 22:34:00 +00:00
CRONFILE=`mktemp`
cat > $CRONFILE <<EOF
2014-08-13 11:28:11 +00:00
* * * * * reprepro-import >> /var/log/reprepro.log
2014-08-12 22:34:00 +00:00
EOF
2014-08-13 11:28:11 +00:00
crontab -u root $CRONFILE
2014-08-12 22:34:00 +00:00
rm -f $CRONFILE
2014-08-12 21:04:26 +00:00
2014-08-13 11:28:11 +00:00
# run import once, to create the right directory structure
reprepro-import
2014-08-12 21:04:26 +00:00
supervisord -n