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

652 lines
21 KiB

#!/usr/bin/env bash
set -e
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
KASM_VERSION="1.7.0"
KASM_INSTALL_BASE="/opt/kasm/${KASM_VERSION}"
DO_DATABASE_INIT='true'
VERBOSE='false'
ACCEPT_EULA='false'
API_INSTALL='false'
PUBLIC_HOSTNAME='false'
DEFAULT_PROXY_LISTENING_PORT='443'
DATABASE_HOSTNAME='false'
MANAGER_HOSTNAME='false'
API_SERVER_HOSTNAME='false'
SERVER_ZONE='default'
SERVER_ID='false'
PROVIDER='false'
bflag=''
files=''
START_SERVICES='true'
DEFAULT_ADMIN_PASSWORD="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 )"
DEFAULT_USER_PASSWORD="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 )"
DEFAULT_DATABASE_PASSWORD="false"
DEFAULT_REDIS_PASSWORD="false"
ROLE="all"
SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
KASM_RELEASE="$(realpath $SCRIPT_PATH)"
EULA_PATH=${KASM_RELEASE}/licenses/LICENSE.txt
function is_port_ok (){
re='^[0-9]+$'
if ! [[ ${DEFAULT_PROXY_LISTENING_PORT} =~ $re ]] ; then
echo "error: DEFAULT_PROXY_LISTENING_PORT, (${DEFAULT_PROXY_LISTENING_PORT}) is not an integer" >&2; exit 1
fi
if ((${DEFAULT_PROXY_LISTENING_PORT} <= 0 || ${DEFAULT_PROXY_LISTENING_PORT} > 65535 )); then
echo "error: DEFAULT_PROXY_LISTENING_PORT, (${DEFAULT_PROXY_LISTENING_PORT}) is in the valid port range"
exit 1
fi
echo "Checking if DEFAULT_PROXY_LISTENING_PORT (${DEFAULT_PROXY_LISTENING_PORT}) is free"
if lsof -Pi :${DEFAULT_PROXY_LISTENING_PORT} -sTCP:LISTEN ; then
echo "Port (${DEFAULT_PROXY_LISTENING_PORT}) is in use. Installation cannot continue."
exit -1
else
echo "Port (${DEFAULT_PROXY_LISTENING_PORT}) is not in use."
fi
}
function set_listening_port(){
if [ "${DEFAULT_PROXY_LISTENING_PORT}" != "443" ] ;
then
echo "Updating configurations with custom DEFAULT_PROXY_LISTENING_PORT (${DEFAULT_PROXY_LISTENING_PORT})"
FILE=${KASM_INSTALL_BASE}/conf/database/seed_data/default_properties.yaml
if [ -f "${FILE}" ]; then
sed -i "s/proxy_port:.*/proxy_port: ${DEFAULT_PROXY_LISTENING_PORT}/g" ${FILE}
fi
FILE=${KASM_INSTALL_BASE}/conf/app/agent.app.config.yaml
if [ -f "${FILE}" ]; then
sed -i "s/public_port.*/public_port: ${DEFAULT_PROXY_LISTENING_PORT}/g" ${FILE}
fi
FILE=${KASM_INSTALL_BASE}/conf/nginx/orchestrator.conf
if [ -f "${FILE}" ]; then
sed -i "s/listen.*/listen ${DEFAULT_PROXY_LISTENING_PORT} ssl ;/g" ${FILE}
fi
grep -rl "443:443" ${KASM_INSTALL_BASE}/docker/ | xargs -I '{}' sed -i "s/- \"443:443\"/- \"${DEFAULT_PROXY_LISTENING_PORT}:${DEFAULT_PROXY_LISTENING_PORT}\"/g" {}
fi
}
function get_public_hostname (){
if [ "${PUBLIC_HOSTNAME}" == "false" ] ;
then
_PUBLIC_IP=$(ip route get 1.1.1.1 | grep -oP 'src \K\S+')
read -p "Enter the network facing IP or hostname [${_PUBLIC_IP}]: " public_hostname_input
if [ "${public_hostname_input}" == "" ] ;
then
PUBLIC_HOSTNAME=${_PUBLIC_IP}
else
PUBLIC_HOSTNAME=${public_hostname_input}
fi
echo "Using ip/hostname: [${PUBLIC_HOSTNAME}]"
fi
}
function get_database_hostname (){
if [ "${DATABASE_HOSTNAME}" == "false" ] ;
then
database_hostname_input=
while [[ $database_hostname_input = "" ]]; do
read -p "Enter the Kasm Database's hostname or IP : " database_hostname_input
done
DATABASE_HOSTNAME=${database_hostname_input}
echo "Using database ip/hostname: [${DATABASE_HOSTNAME}]"
fi
}
function set_random_database_password (){
# Honor the default if its passed in
if [ "${DEFAULT_DATABASE_PASSWORD}" == "false" ] ;
then
DEFAULT_DATABASE_PASSWORD="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 20 )"
fi
}
function set_random_redis_password (){
# Honor the default if its passed in
if [ "${DEFAULT_REDIS_PASSWORD}" == "false" ] ;
then
DEFAULT_REDIS_PASSWORD="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 20 )"
fi
}
function get_database_password (){
if [ "${DEFAULT_DATABASE_PASSWORD}" == "false" ] ;
then
database_password_input=
while [[ $database_password_input = "" ]]; do
read -p "Enter the Kasm Database's password : " database_password_input
done
DEFAULT_DATABASE_PASSWORD=${database_password_input}
echo "Using database password: [${DEFAULT_DATABASE_PASSWORD}]"
fi
}
function get_redis_password (){
if [ "${DEFAULT_REDIS_PASSWORD}" == "false" ] ;
then
redis_password_input=
while [[ $redis_password_input = "" ]]; do
read -p "Enter the Kasm Redis'password : " redis_password_input
done
DEFAULT_REDIS_PASSWORD=${redis_password_input}
echo "Using redis password: [${DEFAULT_REDIS_PASSWORD}]"
fi
}
function get_manager_hostname (){
if [ "${MANAGER_HOSTNAME}" == "false" ] ;
then
manager_hostname_input=
while [[ $manager_hostname_input = "" ]]; do
read -p "Enter the Kasm manager's hostname or IP : " manager_hostname_input
done
MANAGER_HOSTNAME=${manager_hostname_input}
echo "Using manager ip/hostname: [${MANAGER_HOSTNAME}]"
fi
}
function set_public_hostname() {
sed -i "s/public_hostname.*/public_hostname: ${PUBLIC_HOSTNAME}/g" ${KASM_INSTALL_BASE}/conf/app/agent.app.config.yaml
}
function set_default_user_passwords() {
sed -i "s/password: admin.*/password: \"${DEFAULT_ADMIN_PASSWORD}\"/g" ${KASM_INSTALL_BASE}/conf/database/seed_data/default_properties.yaml
sed -i "s/password: user.*/password: \"${DEFAULT_USER_PASSWORD}\"/g" ${KASM_INSTALL_BASE}/conf/database/seed_data/default_properties.yaml
}
function set_database_hostname() {
sed -i "s/host:.*/host: ${DATABASE_HOSTNAME}/g" ${KASM_INSTALL_BASE}/conf/app/api.app.config.yaml
}
function set_database_password() {
sed -i "s/ password:.*/ password: \"${DEFAULT_DATABASE_PASSWORD}\"/g" ${KASM_INSTALL_BASE}/conf/app/api.app.config.yaml
grep -rl POSTGRES_PASSWORD ${KASM_INSTALL_BASE}/docker/ | xargs -I '{}' sed -i "s/POSTGRES_PASSWORD:.*/POSTGRES_PASSWORD: \"${DEFAULT_DATABASE_PASSWORD}\"/g" {}
}
function set_redis_password() {
sed -i "s/redis_password:.*/redis_password: \"${DEFAULT_REDIS_PASSWORD}\"/g" ${KASM_INSTALL_BASE}/conf/app/api.app.config.yaml
grep -rl POSTGRES_PASSWORD ${KASM_INSTALL_BASE}/docker/ | xargs -I '{}' sed -i "s/REDIS_PASSWORD:.*/REDIS_PASSWORD: \"${DEFAULT_REDIS_PASSWORD}\"/g" {}
}
function set_manager_hostname() {
sed -i "s/hostnames: \['proxy.*/hostnames: \['${MANAGER_HOSTNAME}'\]/g" ${KASM_INSTALL_BASE}/conf/app/agent.app.config.yaml
}
function set_agent_server_id() {
if [ "${SERVER_ID}" == "false" ] ;
then
SERVER_ID=$(cat /proc/sys/kernel/random/uuid)
fi
sed -i "s/server_id.*/server_id: ${SERVER_ID}/g" ${KASM_INSTALL_BASE}/conf/app/agent.app.config.yaml
}
function set_server_zone() {
sed -i "s/zone_name.*/zone_name: ${SERVER_ZONE}/g" ${KASM_INSTALL_BASE}/conf/app/api.app.config.yaml
}
function set_api_server_id() {
API_SERVER_ID=$(cat /proc/sys/kernel/random/uuid)
sed -i "s/server_id.*/server_id: ${API_SERVER_ID}/g" ${KASM_INSTALL_BASE}/conf/app/api.app.config.yaml
}
function set_manager_id() {
MANAGER_ID=$(cat /proc/sys/kernel/random/uuid)
sed -i "s/manager_id.*/manager_id: ${MANAGER_ID}/g" ${KASM_INSTALL_BASE}/conf/app/api.app.config.yaml
}
function set_share_id() {
SHARE_ID=$(cat /proc/sys/kernel/random/uuid)
sed -i "s/share_id.*/share_id: ${SHARE_ID}/g" ${KASM_INSTALL_BASE}/conf/app/api.app.config.yaml
}
function set_api_hostname() {
if [ "${API_SERVER_HOSTNAME}" == "false" ] ;
then
API_SERVER_HOSTNAME=$(hostname)
fi
sed -i "s/server_hostname.*/server_hostname: ${API_SERVER_HOSTNAME}/g" ${KASM_INSTALL_BASE}/conf/app/api.app.config.yaml
}
function set_provider() {
if [ "${PROVIDER}" != "false" ] ;
then
sed -i "s/provider.*/provider: ${PROVIDER}/g" ${KASM_INSTALL_BASE}/conf/app/agent.app.config.yaml
fi
}
function base_install() {
chmod +x ${KASM_INSTALL_BASE}/bin/*
chmod +x ${KASM_INSTALL_BASE}/bin/utils/*
chown kasm:kasm -R ${KASM_INSTALL_BASE}
if [ -d "${KASM_RELEASE}/www/" ]; then
cp -r ${KASM_RELEASE}/www/ ${KASM_INSTALL_BASE}/
chmod -R 555 ${KASM_INSTALL_BASE}/www
fi
if [ "${DO_DATABASE_INIT}" == "true" ] ;
then
echo "Initializing Database"
set_default_user_passwords
${KASM_INSTALL_BASE}/bin//utils/db_init -i -s ${KASM_INSTALL_BASE}/conf/database/seed_data/default_properties.yaml
${KASM_INSTALL_BASE}/bin//utils/db_init -s ${KASM_INSTALL_BASE}/conf/database/seed_data/default_images.yaml
rm ${KASM_INSTALL_BASE}/conf/database/seed_data/default_properties.yaml
fi
}
function pull_images() {
echo "Pulling default Kasm Images"
grep "name: kasmweb" ${KASM_RELEASE}/conf/database/seed_data/default_images.yaml | cut -d ":" -f2-3 | xargs -L 1 sudo docker pull
grep "name: registry.fredhs.net" ${KASM_RELEASE}/conf/database/seed_data/default_images.yaml | cut -d ":" -f2-3 | xargs -L 1 sudo docker pull
}
function copy_manager_configs() {
cp -r ${KASM_RELEASE}/conf/nginx/upstream_manager.conf ${KASM_INSTALL_BASE}/conf/nginx/upstream_manager.conf
cp -r ${KASM_RELEASE}/conf/nginx/services.d/manager_api.conf ${KASM_INSTALL_BASE}/conf/nginx/services.d/manager_api.conf
cp -r ${KASM_RELEASE}/conf/nginx/upstream_api.conf ${KASM_INSTALL_BASE}/conf/nginx/upstream_api.conf
cp -r ${KASM_RELEASE}/conf/nginx/services.d/client_api.conf ${KASM_INSTALL_BASE}/conf/nginx/services.d/client_api.conf
cp -r ${KASM_RELEASE}/conf/nginx/services.d/website.conf ${KASM_INSTALL_BASE}/conf/nginx/services.d/website.conf
cp -r ${KASM_RELEASE}/conf/nginx/services.d/upstream_proxy.conf ${KASM_INSTALL_BASE}/conf/nginx/services.d/upstream_proxy.conf
cp -r ${KASM_RELEASE}/conf/nginx/services.d/share_api.conf ${KASM_INSTALL_BASE}/conf/nginx/services.d/share_api.conf
cp -r ${KASM_RELEASE}/conf/nginx/upstream_share.conf ${KASM_INSTALL_BASE}/conf/nginx/upstream_share.conf
}
function copy_api_configs() {
cp -r ${KASM_RELEASE}/conf/nginx/upstream_api.conf ${KASM_INSTALL_BASE}/conf/nginx/upstream_api.conf
cp -r ${KASM_RELEASE}/conf/nginx/services.d/admin_api.conf ${KASM_INSTALL_BASE}/conf/nginx/services.d/admin_api.conf
cp -r ${KASM_RELEASE}/conf/nginx/services.d/client_api.conf ${KASM_INSTALL_BASE}/conf/nginx/services.d/client_api.conf
cp -r ${KASM_RELEASE}/conf/nginx/services.d/subscription_api.conf ${KASM_INSTALL_BASE}/conf/nginx/services.d/subscription_api.conf
cp -r ${KASM_RELEASE}/conf/nginx/services.d/upstream_proxy.conf ${KASM_INSTALL_BASE}/conf/nginx/services.d/upstream_proxy.conf
cp -r ${KASM_RELEASE}/conf/nginx/services.d/website.conf ${KASM_INSTALL_BASE}/conf/nginx/services.d/website.conf
cp -r ${KASM_RELEASE}/conf/nginx/services.d/share_api.conf ${KASM_INSTALL_BASE}/conf/nginx/services.d/share_api.conf
cp -r ${KASM_RELEASE}/conf/nginx/upstream_share.conf ${KASM_INSTALL_BASE}/conf/nginx/upstream_share.conf
}
function create_docker_network() {
kasm_network=kasm_default_network
set +e
sudo docker network inspect ${kasm_network} &> /dev/null
ret=$?
set -e
if [ $ret -ne 0 ]; then
echo "Creating docker network ${kasm_network}"
sudo docker network create --driver=bridge kasm_default_network
else
echo "Docker network ${kasm_network} already exists. Will not create"
fi
}
function accept_eula() {
printf "\n\n"
echo "End User License Agreement"
echo "__________________________"
printf "\n\n"
cat ${EULA_PATH}
printf "\n\n"
echo "A copy of the End User License Agreement is located at:"
echo "${EULA_PATH}"
printf "\n"
read -p "I have read and accept End User License Agreement (y/n)? " choice
case "$choice" in
y|Y )
ACCEPT_EULA="true"
;;
n|N )
echo "Installation cannot continue"
exit 1
;;
* )
echo "Invalid Response"
echo "Installation cannot continue"
exit 1
;;
esac
}
function check_role() {
if [ "${ROLE}" != "all" ] && [ "${ROLE}" != "agent" ] && [ "${ROLE}" != "app" ] && [ "${ROLE}" != "db" ] ;
then
echo "Invalid Role Defined"
display_help
exit 1
fi
}
function display_help() {
echo "Usage: ${0}"
echo "-h Display this help menu"
echo "-v Verbose output"
echo "-e Accept End User License Agreement"
echo "-S Role service to install: [all | app | db | agent ]"
echo "-p Agent <IP/Hostname>"
echo "-d Skip database initialization"
echo "-D Don't start services at the end of installation"
echo "-m Manager IP/Hostname"
echo "-Q Default Database Password"
echo "-U Default User Password"
echo "-P Default Admin Password"
echo "-L Default Proxy Listening Port"
echo "-z Server Zone"
echo "-R Redis Password"
}
while getopts 'etdhvDp:P:q:m:n:i:r:U:Q:L:z:R:S:' flag; do
case "${flag}" in
e)
ACCEPT_EULA='true'
;;
d)
DO_DATABASE_INIT='false'
;;
h)
display_help
exit 0
;;
i)
SERVER_ID=$OPTARG
echo "Setting Agent Server ID as ${SERVER_ID}"
;;
p)
PUBLIC_HOSTNAME=$OPTARG
echo "Setting Public Hostname as ${PUBLIC_HOSTNAME}"
;;
P)
DEFAULT_ADMIN_PASSWORD=$OPTARG
echo "Setting Default Admin Password as ${DEFAULT_ADMIN_PASSWORD}"
;;
L)
DEFAULT_PROXY_LISTENING_PORT=$OPTARG
echo "Setting Default Listening Port as ${DEFAULT_PROXY_LISTENING_PORT}"
;;
U)
DEFAULT_USER_PASSWORD=$OPTARG
echo "Setting Default User Password as ${DEFAULT_USER_PASSWORD}"
;;
Q)
DEFAULT_DATABASE_PASSWORD=$OPTARG
echo "Setting Default Database Password as ${DEFAULT_DATABASE_PASSWORD}"
;;
R)
DEFAULT_REDIS_PASSWORD=$OPTARG
echo "Setting Default Redis Password as ${DEFAULT_REDIS_PASSWORD}"
;;
S)
ROLE=$OPTARG
check_role
echo "Setting Default Redis Password as ${DEFAULT_REDIS_PASSWORD}"
;;
q)
DATABASE_HOSTNAME=$OPTARG
echo "Setting Database Hostname as ${DATABASE_HOSTNAME}"
;;
m)
MANAGER_HOSTNAME=$OPTARG
echo "Setting Manager Hostname as ${MANAGER_HOSTNAME}"
;;
n)
API_SERVER_HOSTNAME=$OPTARG
echo "Setting API Server Hostname as ${API_SERVER_HOSTNAME}"
;;
r)
PROVIDER=$OPTARG
echo "Setting Agent Provider as ${PROVIDER}"
;;
D)
START_SERVICES='false'
;;
v)
set -x
;;
z)
SERVER_ZONE=$OPTARG
echo "Setting Server Zone as ${SERVER_ZONE}"
;;
*)
error "Unexpected option ${flag}"
display_help
;;
esac
done
is_port_ok
if [ "${ACCEPT_EULA}" == "false" ] ;
then
accept_eula
fi
bash ${KASM_RELEASE}/install_dependencies.sh
id -u kasm &>/dev/null || useradd kasm
# TODO Propmpt the user, or accept a flag for automation
sudo rm -rf ${KASM_INSTALL_BASE}
mkdir -p ${KASM_INSTALL_BASE}/bin
mkdir -p ${KASM_INSTALL_BASE}/certs
mkdir -p ${KASM_INSTALL_BASE}/www
mkdir -p ${KASM_INSTALL_BASE}/conf/nginx/services.d
mkdir -p ${KASM_INSTALL_BASE}/conf/nginx/containers.d
mkdir -p ${KASM_INSTALL_BASE}/conf/database/seed_data
mkdir -p ${KASM_INSTALL_BASE}/conf/app
mkdir -p ${KASM_INSTALL_BASE}/log
chmod 777 ${KASM_INSTALL_BASE}/log
chmod 777 ${KASM_INSTALL_BASE}/conf/nginx/containers.d
sudo openssl req -x509 -nodes -days 1825 -newkey rsa:2048 -keyout ${KASM_INSTALL_BASE}/certs/kasm_nginx.key -out ${KASM_INSTALL_BASE}/certs/kasm_nginx.crt -subj "/C=US/ST=VA/L=None/O=None/OU=DoFu/CN=$(hostname)/emailAddress=none@none.none" 2> /dev/null
cp -r ${KASM_RELEASE}/conf/app/* ${KASM_INSTALL_BASE}/conf/app/
cp ${KASM_RELEASE}/conf/database/data.sql ${KASM_INSTALL_BASE}/conf/database/
cp ${KASM_RELEASE}/conf/database/seed_data/default_properties.yaml ${KASM_INSTALL_BASE}/conf/database/seed_data/
cp ${KASM_RELEASE}/conf/database/seed_data/default_images.yaml ${KASM_INSTALL_BASE}/conf/database/seed_data/
chmod -R 444 ${KASM_INSTALL_BASE}/conf/database
cp -r ${KASM_RELEASE}/conf/nginx/orchestrator.conf ${KASM_INSTALL_BASE}/conf/nginx/orchestrator.conf
mkdir -p ${KASM_INSTALL_BASE}/docker/.conf
cp ${KASM_RELEASE}/docker/*.yaml ${KASM_INSTALL_BASE}/docker/.conf/
cp -r ${KASM_RELEASE}/bin/ ${KASM_INSTALL_BASE}/
cp -r ${KASM_RELEASE}/licenses/ ${KASM_INSTALL_BASE}/
cp ${EULA_PATH} ${KASM_INSTALL_BASE}/
if [ "${ROLE}" == "all" ] ;
then
echo "Installing All Services"
cp -r ${KASM_RELEASE}/conf/nginx/upstream_agent.conf ${KASM_INSTALL_BASE}/conf/nginx/upstream_agent.conf
cp -r ${KASM_RELEASE}/conf/nginx/services.d/agent.conf ${KASM_INSTALL_BASE}/conf/nginx/services.d/agent.conf
cp ${KASM_RELEASE}/docker/docker-compose-all.yaml ${KASM_INSTALL_BASE}/docker/docker-compose.yaml
set_agent_server_id
set_provider
copy_manager_configs
copy_api_configs
set_api_hostname
set_api_server_id
set_share_id
set_server_zone
set_manager_id
set_listening_port
create_docker_network
set_random_database_password
set_database_password
set_random_redis_password
set_redis_password
base_install
pull_images
elif [ "${ROLE}" == "app" ] ;
then
echo "Installing App Role"
cp ${KASM_RELEASE}/docker/docker-compose-app.yaml ${KASM_INSTALL_BASE}/docker/docker-compose.yaml
copy_manager_configs
get_database_hostname
set_database_hostname
get_database_password
set_database_password
get_redis_password
set_redis_password
set_api_hostname
set_api_server_id
set_share_id
set_server_zone
set_manager_id
set_listening_port
create_docker_network
DO_DATABASE_INIT='false'
base_install
elif [ "${ROLE}" == "agent" ] ;
then
echo "Installing Agent Role"
cp -r ${KASM_RELEASE}/conf/nginx/upstream_agent.conf ${KASM_INSTALL_BASE}/conf/nginx/upstream_agent.conf
cp -r ${KASM_RELEASE}/conf/nginx/services.d/agent.conf ${KASM_INSTALL_BASE}/conf/nginx/services.d/agent.conf
cp ${KASM_RELEASE}/docker/docker-compose-agent.yaml ${KASM_INSTALL_BASE}/docker/docker-compose.yaml
get_manager_hostname
set_manager_hostname
get_public_hostname
set_public_hostname
set_agent_server_id
set_provider
set_listening_port
create_docker_network
DO_DATABASE_INIT='false'
elif [ "${ROLE}" == "db" ] ;
then
echo "Installing Database Role"
cp ${KASM_RELEASE}/docker/docker-compose-db.yaml ${KASM_INSTALL_BASE}/docker/docker-compose.yaml
create_docker_network
set_random_database_password
set_database_password
set_random_redis_password
set_redis_password
set_listening_port
base_install
else
exit -1
fi
chmod +x ${KASM_INSTALL_BASE}/bin/*
chmod +x ${KASM_INSTALL_BASE}/bin/utils/*
chmod -R 777 ${KASM_INSTALL_BASE}/conf/nginx
# Remove the symbolic links if they already exits
rm -f /opt/kasm/current
rm -f /opt/kasm/bin
# Create symbolic links to the version just installed
ln -sf ${KASM_INSTALL_BASE} /opt/kasm/current
ln -sf /opt/kasm/current/bin /opt/kasm/bin
if [ "${START_SERVICES}" == "true" ] ;
then
echo "Starting Kasm Services"
${KASM_INSTALL_BASE}/bin/start
else
echo "Not starting Kasm Services"
fi
if [ "${ROLE}" == "agent" ] || [ "${ROLE}" == "all" ] ;
then
if [[ $(sudo swapon --show) ]]; then
echo 'Swap Exists'
else
printf "\n--------------------------------------------------------------------------------"
printf "\n WARNING "
printf "\n--------------------------------------------------------------------------------\n\n"
echo 'Your system does not have a Swap file or partition. Even with adequate RAM it is'
echo 'imperative to a have a swap file for Kasm to be stable. You can add a swap file '
echo 'at any time, see our documentations Resource Allocation Section for more details.'
printf "\n"
read -p "Do you want to continue installation? (Swaps may be added at anytime) (y/n)? " choice
case "$choice" in
y|Y )
echo "Finishing Installation..."
;;
n|N )
echo "Installation Exiting"
exit 1
;;
* )
echo "Invalid Response"
echo "Installation Exiting"
exit 1
;;
esac
fi
fi
printf "\n\n"
echo "Installation Complete"
if [ "${DO_DATABASE_INIT}" == "true" ] ;
then
printf "\n\n"
echo "Kasm UI Login Credentials"
printf "\n"
echo "------------------------------------"
echo " username: admin@kasm.local"
echo " password: ${DEFAULT_ADMIN_PASSWORD}"
echo "------------------------------------"
echo " username: user@kasm.local"
echo " password: ${DEFAULT_USER_PASSWORD}"
echo "------------------------------------"
printf "\n"
echo "Kasm Database Credentials"
echo "------------------------------------"
echo " username: kasmapp"
echo " password: ${DEFAULT_DATABASE_PASSWORD}"
echo "------------------------------------"
printf "\n"
echo "Kasm Redis Credentials"
echo "------------------------------------"
echo " password: ${DEFAULT_REDIS_PASSWORD}"
echo "------------------------------------"
printf "\n\n"
fi