Skip to content

Instantly share code, notes, and snippets.

@taksan
Created April 12, 2017 13:59
Show Gist options
  • Save taksan/4872aece92ab9e14eeb7db33dcba3e3b to your computer and use it in GitHub Desktop.
Save taksan/4872aece92ab9e14eeb7db33dcba3e3b to your computer and use it in GitHub Desktop.
[Unit]
Description=Taskboard service
Requires=docker.service
[Service]
Type=simple
User=root
ExecStart=/etc/init.d/taskboard-service start
ExecStop=/etc/init.d/taskboard-service stop
[Install]
WantedBy=multi-user.target
@taksan
Copy link
Author

taksan commented Apr 12, 2017

/etc/systemd/system/docker-iptables.service

[Unit]
Description=Fix to allow docker containers to connect to host ports
After=network.target

[Service]
Type=oneshot
ExecStart=iptables -I INPUT 4 -i docker0 -j ACCEPT

[Install]
WantedBy=default.target

@taksan
Copy link
Author

taksan commented Apr 12, 2017

/etc/init.d/dashboard-service

#! /bin/sh

do_start() {
    iptables -I INPUT 4 -i docker0 -j ACCEPT
    docker run --privileged=true -p 3030:3030 --name lf-smashing -v /opt/smashing-data:/opt/dashboard_config -t devopsobj/liferay-smashing
}

do_stop() {
    docker stop lf-smashing
    docker rm lf-smashing
}

case "$1" in
  start)
    do_start
    ;;
  stop)
    do_stop
    ;;
  restart)
    do_stop
    do_start
    ;;
  update)
    do_stop
    docker pull devopsobj/liferay-smashing
    do_start
    ;;
  *)
    echo "Usage: /etc/init.d/dashboard-service {start|stop|restart|update}"
    exit 1
    ;;
esac

exit 0

@taksan
Copy link
Author

taksan commented Apr 12, 2017

/etc/init.d/jenkins-service

#! /bin/sh

do_start() {
    docker rm -f  lf-jenkins2>/dev/null
    docker run --privileged=true -p 8080:8080 --name lf-jenkins -v /opt/jenkins-data:/var/lib/jenkins/ -d -it devopsobj/liferay-jenkins
}

do_stop() {
    docker stop lf-jenkins
    docker rm -f  lf-jenkins 2>/dev/null
}

case "$1" in
  start)
    do_start
    ;;
  stop)
    do_stop
    ;;
  restart)
    do_stop
    do_start
    ;;
  update)
    do_stop
    docker pull devopsobj/liferay-jenkins
    do_start
    ;;
  *)
    echo "Usage: /etc/init.d/jenkins-service {start|stop|restart|update}"
    exit 1
    ;;
esac

exit 0

@taksan
Copy link
Author

taksan commented Apr 12, 2017

To load the services, reload the daemon:

systemctl daemon-reload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment