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
65 lines
1.3 KiB
Bash
1 year ago
|
#!/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() {
|
||
1 year ago
|
local config=`uci get lxc-attach.@lxc-attach[0].container 2>/dev/null`
|
||
1 year ago
|
|
||
|
#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")
|
||
1 year ago
|
docker rm -f lxc-attach
|
||
1 year ago
|
;;
|
||
|
"start" | "stop" | "restart")
|
||
1 year ago
|
docker ${ACTION} lxc-attach
|
||
1 year ago
|
;;
|
||
|
"status")
|
||
1 year ago
|
docker ps --all -f 'name=lxc-attach' --format '{{.State}}'
|
||
1 year ago
|
;;
|
||
|
"port")
|
||
1 year ago
|
docker ps --all -f 'name=lxc-attach' --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://'
|
||
1 year ago
|
;;
|
||
|
*)
|
||
|
usage
|
||
|
exit 1
|
||
|
;;
|
||
|
esac
|