Select Git revision

David Beniamine authored
kasm 1.35 KiB
#!/bin/bash
is_docker() {
if [ ! -z "$(which docker 2>/dev/null | grep -v 'not found')" ];
then
echo "1"
else
echo "0"
fi
}
usage() {
echo -e "Usage $0 <command> [args]\n"
echo -e "COMMANDS\n"
echo "bash"
echo -e "\topens a shell in kasm"
echo "config"
echo -e "\tquery vncconfig [-list|-get|-set|desc] args"
echo "down"
echo -e "\tStops the services"
echo "reset_passwd"
echo -e "\tReinitialize the passowrd"
echo "restart"
echo -e "\trestarts the services"
echo "up"
echo -e "\tStarts the services"
}
if [ "$(is_docker)" -eq 1 ]; then
if [ ! -z "$(which docker-compose 2>/dev/null)" ]; then
compose="docker-compose"
else
compose="docker compose"
fi
cmd="$compose exec kasm"
fi
action=$1
shift
# Keep actions sorted
case $action in
"bash")
$cmd bash
;;
"config")
if [ -z "$1" ]; then
args="-list"
else
args="$@"
fi
$cmd vncconfig $args
;;
"down")
$compose down $@
;;
"reset_passwd")
$cmd rm .htpasswd
$compose down
$compose up -d
;;
"restart")
$compose restart
;;
"up")
$compose up $@
;;
*)
echo "ERROR: No command given"
usage
exit 1
esac