Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
7 changes: 7 additions & 0 deletions jmsctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ function service_to_docker_name() {
EXE=""

function start() {
target="/opt/jumpserver/installer"
if [[ -L "${target}" ]]; then
rm -f "${target}"
fi
if [[ ! -e "${target}" ]]; then
ln -s "${PROJECT_DIR}" "${target}" || echo ""
fi
${EXE} up -d
}

Expand Down
9 changes: 6 additions & 3 deletions scripts/0_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ function prepare_image_files() {
echo "$(gettext 'Docker is not running, please install and start') ..."
exit 1
fi

if [[ ! -d "${IMAGE_DIR}" ]]; then
mkdir -p "${IMAGE_DIR}"
fi
rm -f "${IMAGE_DIR}/*"

pull_images

images=$(get_images)
Expand All @@ -78,9 +84,6 @@ function prepare_image_files() {
saved_id=$(cat "${md5_path}")
fi

if [[ ! -d "${IMAGE_DIR}" ]]; then
mkdir -p "${IMAGE_DIR}"
fi

if [[ -f "${image_path}" ]]; then
if [[ "${image_id}" != "${saved_id}" ]]; then
Expand Down
13 changes: 1 addition & 12 deletions scripts/1_config_jumpserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,8 @@ function set_service() {
fi
}

function init_db() {
echo_yellow "\n6. $(gettext 'Init JumpServer Database')"
if ! perform_db_migrations; then
log_error "$(gettext 'Failed to change the table structure')!"
exit 1
fi
}

function set_others() {
echo_yellow "\n7. $(gettext 'Configure Others')"
echo_yellow "\n6. $(gettext 'Configure Others')"
lang=$(get_config LANGUAGE_CODE "zh")
read_from_input lang "$(gettext 'Please enter language')" "zh/en/ja/es/ko/ru/vi" "${lang}"
set_config LANGUAGE_CODE "${lang}"
Expand Down Expand Up @@ -269,9 +261,6 @@ function main() {
if set_others; then
echo_done
fi
if init_db; then
echo_done
fi
}

if [[ "$0" == "${BASH_SOURCE[0]}" ]]; then
Expand Down
14 changes: 12 additions & 2 deletions scripts/4_install_jumpserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function pre_install() {
if [[ -n "$UNCHECK_DEPENDENCIES" ]]; then
return 0
fi

if ! command -v systemctl &>/dev/null; then
docker version &>/dev/null || {
log_error "$(gettext 'The current Linux system does not support systemd management. Please deploy docker by yourself before running this script again')"
Expand All @@ -19,6 +20,7 @@ function pre_install() {
exit 1
}
fi

if ! command -v iptables &>/dev/null; then
log_error "$(gettext 'command not found, Please install it first') iptables"
exit 1
Expand Down Expand Up @@ -93,14 +95,22 @@ function main() {
exit 1
fi

echo_green "\n>>> $(gettext 'Install and Configure JumpServer')"
if ! bash "${BASE_DIR}/1_config_jumpserver.sh"; then
exit 1
fi

echo_green "\n>>> $(gettext 'Loading Docker Image')"
if ! bash "${BASE_DIR}/3_load_images.sh"; then
exit 1
fi
echo_green "\n>>> $(gettext 'Install and Configure JumpServer')"
if ! bash "${BASE_DIR}/1_config_jumpserver.sh"; then

echo_green "\n>>> $(gettext 'Initialize Database')"
if ! perform_db_migrations; then
log_error "$(gettext 'Failed to change the table structure')!"
exit 1
fi

installation_log "install"
post_install
}
Expand Down
7 changes: 7 additions & 0 deletions scripts/logo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

██╗██╗ ██╗███╗ ███╗██████╗ ███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗
██║██║ ██║████╗ ████║██╔══██╗██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗
██║██║ ██║██╔████╔██║██████╔╝███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝
██ ██║██║ ██║██║╚██╔╝██║██╔═══╝ ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗
╚█████╔╝╚██████╔╝██║ ╚═╝ ██║██║ ███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║
╚════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝
161 changes: 70 additions & 91 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"

. "${BASE_DIR}/const.sh"

common_services=(core celery koko lion chen web)
xpack_services=(magnus razor xrdp video panda nec facelive)

function check_root() {
[[ "$(id -u)" == 0 ]]
}
Expand Down Expand Up @@ -48,7 +51,11 @@ function has_config() {
function get_config() {
key=$1
default=${2-''}
value=$(grep "^${key}=" "${CONFIG_FILE}" | awk -F= '{ print $2 }' | awk -F' ' '{ print $1 }' | tail -1)

if [[ -f "${CONFIG_FILE}" ]]; then
value=$(grep "^${key}=" "${CONFIG_FILE}" | awk -F= '{ print $2 }' | awk -F' ' '{ print $1 }' | tail -1)
fi

if [[ -z "$value" ]];then
value="$default"
fi
Expand Down Expand Up @@ -138,6 +145,40 @@ function check_db_data() {
fi
}

function get_enabled_services() {
enabled_services=()

use_xpack=$(get_config_or_env USE_XPACK)
services=("${common_services[@]}")
if [[ "${use_xpack}" == "1" ]]; then
services+=("${xpack_services[@]}")
fi

for service in "${services[@]}"; do
key=$(echo "$service" | tr '[:lower:]' '[:upper:]')
key="${key}_ENABLED"
key=$(echo "$key" | sed 's/-/_/g')
if [[ "${service}" == "video-worker" ]]; then
key="VIDEO_ENABLED"
fi
if [[ "$(get_config_or_env "${key}")" != "0" ]]; then
enabled_services+=("${service}")
fi
done

echo "${enabled_services[@]}"
}

function get_config_enabled() {
key=$1
value=$(get_config "${key}")
if [[ "${value}" == "0" || "${value}" == "false" || "${value}" == "False" ]]; then
return 0
else
return 1
fi
}

function get_db_info() {
info_type=$1
db_engine=$(get_config DB_ENGINE "mysql")
Expand Down Expand Up @@ -179,7 +220,7 @@ function get_db_info() {
elif [[ "${mariadb_data_exists}" == "1" ]]; then
echo "compose/mariadb.yml"
elif [[ "${postgres_data_exists}" == "1" ]]; then
echo "compose/postgres.yml"
echo "compose/postgresql.yml"
fi
;;
*)
Expand All @@ -197,34 +238,24 @@ function get_db_images_file() {

function get_images() {
use_xpack=$(get_config_or_env USE_XPACK)
db_images=$(get_db_images)
images=(
"redis:7.4.6-bookworm"
"${db_images}"
)
for image in "${images[@]}"; do
echo "${image}"
images=("redis:7.4.6-bookworm")
images+=("$(get_db_images)")
enabled_services=$(get_enabled_services)

for service in ${enabled_services}; do
if [[ "${service}" == "video" ]]; then
image="jumpserver/video-worker:${VERSION}"
elif [[ "${service}" == "" || "${service}" == "celery" ]]; then
continue
else
image="jumpserver/${service}:${VERSION}"
fi
if [[ "${use_xpack}" == "1" ]]; then
image="registry.fit2cloud.com/${image}"
fi
images+=("${image}")
done
if [[ "$use_xpack" == "1" ]];then
echo "registry.fit2cloud.com/jumpserver/core:${VERSION}"
echo "registry.fit2cloud.com/jumpserver/koko:${VERSION}"
echo "registry.fit2cloud.com/jumpserver/lion:${VERSION}"
echo "registry.fit2cloud.com/jumpserver/chen:${VERSION}"
echo "registry.fit2cloud.com/jumpserver/web:${VERSION}"
echo "registry.fit2cloud.com/jumpserver/magnus:${VERSION}"
echo "registry.fit2cloud.com/jumpserver/razor:${VERSION}"
echo "registry.fit2cloud.com/jumpserver/video-worker:${VERSION}"
echo "registry.fit2cloud.com/jumpserver/xrdp:${VERSION}"
echo "registry.fit2cloud.com/jumpserver/panda:${VERSION}"
echo "registry.fit2cloud.com/jumpserver/nec:${VERSION}"
echo "registry.fit2cloud.com/jumpserver/facelive:${VERSION}"
else
echo "jumpserver/core:${VERSION}"
echo "jumpserver/koko:${VERSION}"
echo "jumpserver/lion:${VERSION}"
echo "jumpserver/chen:${VERSION}"
echo "jumpserver/web:${VERSION}"
fi
echo "${images[@]}"
}

function read_from_input() {
Expand All @@ -248,6 +279,12 @@ function read_from_input() {
fi

echo -n "${msg}: "
if [[ "${AUTO_INSTALL}" == "1" ]]; then
echo "${default}"
export "${var}"="${default}"
return
fi

read -r input
if [[ -z "${input}" && -n "${default}" ]]; then
export "${var}"="${default}"
Expand Down Expand Up @@ -336,12 +373,7 @@ function get_docker_compose_services() {

use_xpack=$(get_config_or_env USE_XPACK)

services="core celery koko lion chen web"

receptor_enabled=$(get_config RECEPTOR_ENABLED)
if [[ "${receptor_enabled}" == "1" ]]; then
services+=" receptor"
fi
services=$(get_enabled_services)

if [[ "${ignore_db}" != "ignore_db" ]]; then
case "${db_engine}" in
Expand All @@ -355,23 +387,10 @@ function get_docker_compose_services() {
[[ "${redis_host}" == "redis" ]] && services+=" redis"
fi

for service in core celery koko lion chen web; do
enabled=$(get_config "${service^^}_ENABLED")
[[ "${enabled}" == "0" ]] && services="${services//${service}/}"
done

[[ "${use_es}" == "1" ]] && services+=" es"
[[ "${use_minio}" == "1" ]] && services+=" minio"
[[ "${use_loki}" == "1" ]] && services+=" loki"

if [[ "${use_xpack}" == "1" ]]; then
services+=" magnus razor xrdp video panda nec facelive"
for service in magnus razor xrdp video panda nec facelive; do
enabled=$(get_config "${service^^}_ENABLED")
[[ "${enabled}" == "0" ]] && services="${services//${service}/}"
done
fi

echo "${services}"
}

Expand All @@ -381,6 +400,7 @@ function get_docker_compose_cmd_line() {
use_xpack=$(get_config_or_env USE_XPACK)
https_port=$(get_config HTTPS_PORT)
db_images_file=$(get_db_images_file)

cmd="docker compose"
if [[ "${use_ipv6}" != "1" ]]; then
cmd+=" -f compose/network.yml"
Expand All @@ -389,42 +409,10 @@ function get_docker_compose_cmd_line() {
fi
services=$(get_docker_compose_services "$ignore_db")

for service in core celery receptor koko lion chen web redis; do
if [[ "${services}" =~ ${service} ]]; then
for service in $services; do
cmd+=" -f compose/${service}.yml"
fi
done

if [[ "${services}" =~ "mysql" || "${services}" =~ "postgresql" ]]; then
cmd+=" -f ${db_images_file}"
fi

use_es=$(get_config USE_ES)
if [[ "${use_es}" == "1" ]]; then
cmd+=" -f compose/es.yml"
fi

use_minio=$(get_config USE_MINIO)
if [[ "${use_minio}" == "1" ]]; then
cmd+=" -f compose/minio.yml"
fi

if [[ -n "${https_port}" ]]; then
cmd+=" -f compose/lb.yml"
fi

if [[ "${services}" =~ loki ]]; then
cmd+=" -f compose/loki.yml"
fi

if [[ "${use_xpack}" == '1' ]]; then
for service in magnus razor xrdp video panda nec facelive; do
if [[ "${services}" =~ ${service} ]]; then
cmd+=" -f compose/${service}.yml"
fi
done
fi

echo "${cmd}"
}

Expand Down Expand Up @@ -543,16 +531,7 @@ function prepare_config() {
}

function echo_logo() {
cat <<"EOF"

██╗██╗ ██╗███╗ ███╗██████╗ ███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗
██║██║ ██║████╗ ████║██╔══██╗██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗
██║██║ ██║██╔████╔██║██████╔╝███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝
██ ██║██║ ██║██║╚██╔╝██║██╔═══╝ ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗
╚█████╔╝╚██████╔╝██║ ╚═╝ ██║██║ ███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║
╚════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝

EOF
cat "${BASE_DIR}/logo.txt"

echo -e "\t\t\t\t\t\t\t\t Version: \033[33m $VERSION \033[0m \n"
}
Expand Down
7 changes: 6 additions & 1 deletion static.env
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
export VERSION=dev
export VERSION=v4.10.15-osm
export USE_XPACK=1
export REGISTRY=registry.fit2cloud.com
export XRDP_ENABLED=0
export FACELIVE_ENABLED=0
export VIDEO_ENABLED=0