Created
December 23, 2014 15:34
-
-
Save bartmeuris/4f99020b9942f6a24696 to your computer and use it in GitHub Desktop.
Irssi Docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mount an external volume on /irssi for persistent storage | |
FROM ubuntu:14.04 | |
MAINTAINER Bart Meuris | |
RUN apt-get update && \ | |
apt-get -y install irssi irssi-scripts && \ | |
useradd irssi && \ | |
mkdir -p /home/irssi && \ | |
chown -R irssi:irssi /home/irssi && \ | |
mkdir /config && \ | |
chown irssi:irssi /config && \ | |
ln -s /config /home/irssi/.irssi | |
USER irssi | |
ENV HOME /home/irssi | |
ENTRYPOINT [ "/usr/bin/irssi" ] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IMAGENAME=irssi | |
NAME="irssi-$USER" | |
# Create data container if it does not exist | |
DATANAME="${NAME}-data" | |
if ! docker ps -a | grep -q -- "${DATANAME}"'[ ]*$'; then | |
echo "irssi data container missing - creating..." | |
docker run --name "${DATANAME}" --hostname "${DATANAME}" -v /config ubuntu:14.04 /bin/bash -c "chown -R 1000:1000 /config" | |
fi | |
NAMES="--name $NAME --hostname $NAME" | |
TIMEZONE="-v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro" | |
# Test if container exists, attach if it does, otherwise start a new-one | |
if docker ps | grep -q -- "${NAME}"'[ ]*$'; then | |
echo "Attaching..." | |
docker attach $NAME | |
exit | |
elif docker ps -a | grep -q -- "${NAME}"'[ ]*$'; then | |
docker rm $NAME | |
fi | |
docker run -t -i --sig-proxy $TIMEZONE --volumes-from "${DATANAME}" $NAMES $IMAGENAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment