provide ability to switch on SSH support per container

This commit is contained in:
Michael Becker 2025-01-14 17:36:11 -05:00
parent 9ab581b79a
commit f98b89c44a
3 changed files with 40 additions and 3 deletions

View File

@ -19,6 +19,14 @@ if [ "$1" == "--port" ]; then
fi
ENABLE_SSH=""
if [ "$1" == "--enable-ssh" ]; then
ENABLE_SSH="true"
shift
fi
# generate random UUID for new SUV
# thanks https://stackoverflow.com/questions/34328759
# SUV_ID=$(hexdump -vn8 -e'2/4 "%08x" 1 "\n"' /dev/urandom)
@ -69,9 +77,11 @@ sleep 3
# docker inspect $SUV_NAME
SUV_IP=$(docker container exec $SUV_NAME hostname -i)
if [ $? -ne 0 ]; then
Q=$?
if [ $Q -ne 0 ]; then
echo "Something went wrong; please check your configuration"
exit $Q
else
@ -81,3 +91,10 @@ else
echo "$SUV_NAME : $SUV_IP"
fi
if [ "$ENABLE_SSH" == "true" ]; then
docker container exec $SUV_NAME /usr/lib/mocha/create_suv_users
docker container exec $SUV_NAME service ssh start
fi

View File

@ -0,0 +1,21 @@
#!/bin/bash
# rm /var/www/html/index.html
# set up mocha user accounts
addgroup webmasters
PASS1=$(pwgen 16 1)
useradd -p $(openssl passwd -6 $PASS1) -g webmasters webmaster
PASS2=$(pwgen 16 1)
useradd -p $(openssl passwd -6 $PASS2) zqadmin
echo "webmaster: $PASS1
zqadmin: $PASS2" > /etc/mocha/passwd
chown --recursive zqadmin /etc/mocha /usr/lib/mocha /usr/share/mocha /var/mocha
chgrp --recursive zqadmin /etc/mocha /usr/lib/mocha /usr/share/mocha /var/mocha
chown --recursive webmaster /var/www /var/mocha/uploads
chgrp --recursive webmasters /var/www /var/mocha/uploads

View File

@ -1,5 +1,5 @@
FROM ubuntu
RUN apt update && apt upgrade -y && apt install -y php php-mbstring php-curl php-xml pwgen dotnet-runtime-8.0
RUN apt update && apt upgrade -y && apt install -y php php-mbstring php-curl php-xml pwgen dotnet-runtime-8.0 openssh-server
RUN rm /var/www/html/index.html && a2enmod ssl && a2enmod rewrite && service apache2 restart
@ -30,4 +30,3 @@ COPY mocha-suv/docker/site.conf /etc/apache2/sites-available/000-default.conf
EXPOSE 443
CMD [ "mochactl", "start" ]