Skip to content

Commit

Permalink
Merge pull request #100 from jumpserver/dev
Browse files Browse the repository at this point in the history
v2.11.0 rc3
  • Loading branch information
BaiJiangJie authored Jun 15, 2021
2 parents 6bd9560 + 1b5c6c7 commit 4a385dd
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
3 changes: 3 additions & 0 deletions config-example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ SESSION_EXPIRE_AT_BROWSER_CLOSE=true

# Koko Lion XRDP 组件配置
CORE_HOST=http://core:8080

# 额外的配置
CURRENT_VERSION=
1 change: 1 addition & 0 deletions scripts/2_install_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function check_docker_config() {
function start_docker() {
if command -v systemctl > /dev/null; then
systemctl daemon-reload
systemctl enable docker
systemctl start docker
fi
docker ps >/dev/null 2>&1
Expand Down
1 change: 1 addition & 0 deletions scripts/4_install_jumpserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function main() {
set_lang
pre_install
prepare_config
set_current_version
echo_green "\n>>> $(gettext 'Install and Configure Docker')"
if ! bash "${BASE_DIR}/2_install_docker.sh"; then
exit 1
Expand Down
3 changes: 2 additions & 1 deletion scripts/5_db_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ PROJECT_DIR=$(dirname ${BASE_DIR})
# shellcheck source=./util.sh
. "${BASE_DIR}/utils.sh"
BACKUP_DIR=/opt/jumpserver/db_backup
CURRENT_VERSION=$(get_config CURRENT_VERSION)

HOST=$(get_config DB_HOST)
PORT=$(get_config DB_PORT)
USER=$(get_config DB_USER)
PASSWORD=$(get_config DB_PASSWORD)
DATABASE=$(get_config DB_NAME)
DB_FILE=${BACKUP_DIR}/${DATABASE}-${VERSION}-$(date +%F_%T).sql
DB_FILE=${BACKUP_DIR}/${DATABASE}-${CURRENT_VERSION}-$(date +%F_%T).sql

function main() {
mkdir -p ${BACKUP_DIR}
Expand Down
25 changes: 21 additions & 4 deletions scripts/7_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

target=$1

function upgrade_config() {
# 如果配置文件有更新, 则添加到新的配置文件
rdp_port=$(get_config RDP_PORT)
if [[ -z "${rdp_port}" ]]; then
RDP_PORT=3389
set_config RDP_PORT "${RDP_PORT}"
fi
current_version=$(get_config CURRENT_VERSION)
if [ -z "${current_version}" ]; then
set_config CURRENT_VERSION "${VERSION}"
fi
}

function migrate_coco_to_koko_v1_54_to_v1_55() {
volume_dir=$(get_config VOLUME_DIR)
coco_dir="${volume_dir}/coco"
Expand Down Expand Up @@ -113,18 +126,22 @@ function main() {
export VERSION=${to_version}
fi
echo
update_config_if_need && echo_done || (echo_failed; exit 1)
update_config_if_need && echo_done || (echo_failed; exit 1)

echo_yellow "\n4. $(gettext 'Loading Docker Image')"
bash "${BASE_DIR}/3_load_images.sh" || exit 1

echo_yellow "\n4. $(gettext 'Backup database')"
echo_yellow "\n5. $(gettext 'Backup database')"
backup_db || exit 1

echo_yellow "\n5. $(gettext 'Apply database changes')"
echo_yellow "\n6. $(gettext 'Apply database changes')"
echo "$(gettext 'Changing database schema may take a while, please wait patiently')"
db_migrations || exit 1

echo_yellow "\n6. $(gettext 'Upgrade successfully. You can now restart the program')"
echo_yellow "\n7. $(gettext 'Upgrade successfully. You can now restart the program')"
echo "./jmsctl.sh restart"
echo -e "\n\n"
set_current_version
}

if [[ "$0" == "${BASH_SOURCE[0]}" ]]; then
Expand Down
10 changes: 4 additions & 6 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,9 @@ function check_ipv6_iptables_if_need() {
fi
}

function upgrade_config() {
# 如果配置文件有更新, 则添加到新的配置文件
rdp_port=$(get_config RDP_PORT)
if [[ -z "${rdp_port}" ]]; then
RDP_PORT=3389
set_config RDP_PORT "${RDP_PORT}"
function set_current_version(){
current_version=$(get_config CURRENT_VERSION)
if [ "${current_version}" != "${VERSION}" ]; then
set_config CURRENT_VERSION "${VERSION}"
fi
}

0 comments on commit 4a385dd

Please sign in to comment.