Update Base to Ubuntu 16.04

disable ipv6 internally
This commit is contained in:
Tommi2Day
2016-10-17 20:34:30 +02:00
parent ed5c484921
commit 669dd83b62
4 changed files with 53 additions and 38 deletions

View File

@@ -1,23 +1,21 @@
FROM ubuntu:trusty FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND noninteractive
RUN mkdir -p /usr/lib/unifi/data /backups /logs RUN mkdir -p /usr/lib/unifi/data /backups /logs
# add unifi repo +keys # add unifi repo +keys
RUN \ RUN echo "deb http://www.ubnt.com/downloads/unifi/debian unifi5 ubiquiti" >/etc/apt/sources.list.d/ubnt.list && \
echo "deb http://www.ubnt.com/downloads/unifi/debian unifi5 ubiquiti" >/etc/apt/sources.list.d/ubnt.list && \ apt-key adv --keyserver keyserver.ubuntu.com --recv C0A52C50
apt-key adv --keyserver keyserver.ubuntu.com --recv C0A52C50
# update then install # update then install
RUN \ RUN apt-get update -q -y && \
apt-get update -q -y && \ apt-get install -q -y mongodb-server unifi lsof anacron vim net-tools less
apt-get install -q -y mongodb-server unifi lsof
#add scripts #add scripts
COPY ["unifi.sh","backup_unifi.sh","restore_unifi.sh", "/usr/lib/unifi/"] COPY ["unifi.sh","backup_unifi.sh","restore_unifi.sh", "/usr/lib/unifi/"]
RUN echo "10 02 * * * root /usr/lib/unifi/backup_unifi.sh >/logs/backup.log 2>&1" >/etc/cron.d/unifi_backup RUN echo "10 02 * * * root /usr/lib/unifi/backup_unifi.sh >/logs/backup.log 2>&1" >/etc/cron.d/unifi_backup
#redirect path #redirect logs and backup
RUN rm -f /usr/lib/unifi/logs && ln -s /logs /usr/lib/unifi/logs RUN rm -f /usr/lib/unifi/logs && ln -s /logs /usr/lib/unifi/logs
RUN rm -f /usr/lib/unifi/backups && ln -s /backups /usr/lib/unifi/backups RUN rm -f /usr/lib/unifi/backups && ln -s /backups /usr/lib/unifi/backups
@@ -25,5 +23,8 @@ RUN rm -f /usr/lib/unifi/backups && ln -s /backups /usr/lib/unifi/backups
VOLUME /usr/lib/unifi/data VOLUME /usr/lib/unifi/data
VOLUME /backups /logs VOLUME /backups /logs
EXPOSE 8443 8880 8080 27117 EXPOSE 8443 8880 8080 27117
#Runtime Env
ENV PATH "$PATH:/usr/lib/unifi"
WORKDIR /usr/lib/unifi WORKDIR /usr/lib/unifi
CMD ["/usr/lib/unifi/unifi.sh", "start"] CMD ["/usr/lib/unifi/unifi.sh", "start"]

View File

@@ -1,11 +1,16 @@
#!/bin/bash #!/bin/bash
VERSION=5.2.9
VMNAME=${1:-unifi5} VMNAME=${1:-unifi5}
if [ -r Dockerfile.$VMNAME ]; then if [ -r Dockerfile.$VMNAME ]; then
DOCKER_USER=${DOCKER_USER:-tommi2day} DOCKER_USER=${DOCKER_USER:-tommi2day}
#build the container #build the container
docker stop $VMNAME docker stop $VMNAME
docker rm $VMNAME docker rm $VMNAME
docker build -t $DOCKER_USER/$VMNAME -f Dockerfile.$VMNAME . docker build -t $DOCKER_USER/$VMNAME:$VERSION -f Dockerfile.$VMNAME . |tee build.log
IMAGE=$(awk '/^Successfully/ {print $3}' build.log)
if [ -n "$IMAGE" ]; then
docker tag $IMAGE $DOCKER_USER/$VMNAME:latest
fi
else else
echo "Usage: $0 VMNAME #Dockerfile.VMNAME must exists" echo "Usage: $0 VMNAME #Dockerfile.VMNAME must exists"
fi fi

View File

@@ -20,9 +20,9 @@ fi
RUNNING=$($DOCKER inspect --format="{{ .State.Running }}" $VMNAME 2> /dev/null) RUNNING=$($DOCKER inspect --format="{{ .State.Running }}" $VMNAME 2> /dev/null)
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
if [ "$RUNNING" == "true" ]; then if [ "$RUNNING" == "true" ]; then
$DOCKER stop $VMNAME $DOCKER stop $VMNAME >/dev/null 2>&1
fi fi
$DOCKER rm $VMNAME $DOCKER rm $VMNAME >/dev/null 2>&1
fi fi
if [ "$DEBUG" = "clean" ]; then if [ "$DEBUG" = "clean" ]; then
@@ -31,32 +31,40 @@ if [ "$DEBUG" = "clean" ]; then
$DOCKER volume rm ${VMNAME}_data >/dev/null 2>&1 $DOCKER volume rm ${VMNAME}_data >/dev/null 2>&1
fi fi
#check data volume and create a new one if needed
DATA=$($DOCKER docker inspect --format '{{ .Mountpoint }}' ${VMNAME}_data 2> /dev/null)
if [ $? -ne 0 ]; then
docker volume create --name ${VMNAME}_data
fi
#prepare shared dir #prepare shared dir
for d in backups logs ; do for d in backups logs data; do
if [ ! -d $SHARED_DIR/$d ]; then if [ ! -d $SHARED_DIR/$d ]; then
mkdir -p $SHARED_DIR/$d mkdir -p $SHARED_DIR/$d
fi fi
done done
#check data volume and create a new one if needed
if [ "OSTYPE" = "msys" ]; then
#on windows use a volume
DATA=$($DOCKER docker inspect --format '{{ .Mountpoint }}' ${VMNAME}_data 2> /dev/null)
if [ $? -ne 0 ]; then
docker volume create --name ${VMNAME}_data --driver=local --
fi
DATA="${VMNAME}_data"
else
DATA="${SHARED_DIR}/data"
fi
#run it #run it
echo " echo "
$DOCKER run $RUN \ $DOCKER run $RUN \
-v ${VMNAME}_data:/usr/lib/unifi/data \ -v $DATA:/usr/lib/unifi/data \
-v "${SHARED_DIR}/backups":/backups \ -v "${SHARED_DIR}/backups":/backups \
-v "${SHARED_DIR}/logs":/logs \ -v "${SHARED_DIR}/logs":/logs \
--hostname $VMNAME \ --hostname $VMNAME \
--name ${VMNAME} \ --name ${VMNAME} \
-p 8080:8080 \ -p :8080:8080 \
-p 8880:8880 \ -p 8880:8880 \
-p 8443:8443 \ -p 8443:8443 \
-p 27117:27117 \ -p 37117:27117 \
$DOCKER_USER/$VMNAME $1 " >starter $DOCKER_USER/$VMNAME $1 " >starter
if [ "$OSTYPE" = "msys" ]; then if [ "$OSTYPE" = "msys" ]; then
mv starter starter.ps1 mv starter starter.ps1
powershell -File starter.ps1 powershell -File starter.ps1

View File

@@ -2,20 +2,21 @@
# description: Start Unify server # description: Start Unify server
# chkconfig: 2345 99 01 # chkconfig: 2345 99 01
#MEMORY="-Xmx256M"
UNIFI=/usr/lib/unifi UNIFI=/usr/lib/unifi
if [ ! -d $UNIFI ]; then if [ ! -d $UNIFI ]; then
echo "Unifi not installed in $UNIFI" echo "Unifi not installed in $UNIFI"
exit 1 exit 1
fi fi
cd $UNIFI cd $UNIFI
case "$1" in case "$1" in
start) start)
if [ ! -d logs ]; then if [ ! -d logs ]; then
mkdir logs mkdir logs
fi fi
nohup java -Xmx256M -jar lib/ace.jar start >logs/unifi.log 2>&1 & nohup java -Djava.net.preferIPv4Stack=true $MEMORY -jar lib/ace.jar start >logs/unifi.log 2>&1 &
sleep 5 sleep 5
./$0 status ./$0 status
tail -f logs/server.log tail -f logs/server.log