Hi All,

I looked around and didn't find a script that generates systemd unit files for 
containers.

Here is the script. I hope people find it useful and it is included by default 
in lxc upstream.

Thanks

-----------------
#!/bin/bash

function usage()
{
  echo "Usage:$0 enable|disable <container name>"
}

if [ $# -lt 2 ] ;
then
  usage
  exit -1;
fi

export UNITFILE=/etc/systemd/system/multi-user.target.wants/$2_container.service


case $1 in
enable)
  cat <<EOF > $UNITFILE
[Unit]
Description=Container $2 service

[Service]
Type=forking
ExecStart=/usr/bin/lxc-start -d -n $2
ExecStop=/usr/bin/lxc-stop -n $2
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF
  
  ;;
disable)
  rm $UNITFILE
  ;;
*)
  usage
  ;;
esac

-----------------
-- 
Regards
 Shridhar

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users

Reply via email to