You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.3 KiB
Bash

#!/bin/sh
ACTION=${1}
shift 1
get_image() {
GEN_PASS=$(< /dev/urandom tr -dc A-Za-z0-9 2>/dev/null | head -c14; echo)
}
do_install_detail() {
local config=`uci get lxc-attach.@lxc-attach[0].container 2>/dev/null`
#Generate the generic environment variables for the docker-compose
# Get our local LAN IP Address
LAN_IP=$(uci get network.lan.ipaddr)
# Strip trailing network mask
LAN_IP="${LAN_IP%/*}"
echo "Entering LXC container"
lxc-attach -n "$config"
}
usage() {
echo "usage: $0 sub-command"
echo "where sub-command is one of:"
echo " install Install lxc-attach"
echo " upgrade Upgrade lxc-attach"
echo " rm/start/stop/restart Remove/Start/Stop/Restart lxc-attach"
echo " status lxc-attach status"
echo " port lxc-attach port"
}
case ${ACTION} in
"install")
get_image
do_install_detail
;;
"upgrade")
get_image
do_install_detail
;;
"rm")
docker rm -f lxc-attach
;;
"start" | "stop" | "restart")
docker ${ACTION} lxc-attach
;;
"status")
docker ps --all -f 'name=lxc-attach' --format '{{.State}}'
;;
"port")
docker ps --all -f 'name=lxc-attach' --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://'
;;
*)
usage
exit 1
;;
esac