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 lxdterm.@lxdterm[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 lxdterm"
echo " upgrade Upgrade lxdterm"
echo " rm/start/stop/restart Remove/Start/Stop/Restart lxdterm"
echo " status lxdterm status"
echo " port lxdterm port"
}
case ${ACTION} in
"install")
get_image
do_install_detail
;;
"upgrade")
get_image
do_install_detail
;;
"rm")
docker rm -f lxdterm
;;
"start" | "stop" | "restart")
docker ${ACTION} lxdterm
;;
"status")
docker ps --all -f 'name=lxdterm' --format '{{.State}}'
;;
"port")
docker ps --all -f 'name=lxdterm' --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://'
;;
*)
usage
exit 1
;;
esac