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

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() {
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 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"
1 year ago
}
case ${ACTION} in
"install")
get_image
do_install_detail
;;
"upgrade")
get_image
do_install_detail
;;
"rm")
docker rm -f lxc-attach
1 year ago
;;
"start" | "stop" | "restart")
docker ${ACTION} lxc-attach
1 year ago
;;
"status")
docker ps --all -f 'name=lxc-attach' --format '{{.State}}'
1 year ago
;;
"port")
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