程序员

【Shell Script】带参数

2022-10-27  本文已影响0人  Lyudmilalala

位置参数,带默认值

#!/bin/bash

env=${1}
backend_package_name=${2}
backend_encode_salt=${3}
init_server_mem=${4}
max_server_mem=${5}

if [ -z "$init_server_mem" ];then
    init_server_mem=2g
fi

if [ -z "$max_server_mem" ];then
    max_server_mem=2g
fi

if [ $# -lt 3 ]; then
    echo "[ERROR] No enough arguments. Please run script as bash build.sh <env> <backend_package_name> <backend_port> <build_prefix> <backend_encode_salt>"
    exit 1
fi

echo "nohup java -jar -Xms$init_server_mem -Xmx$max_server_mem -Djasypt.encryptor.password=$backend_encode_salt -Dspring.profiles.active=$env $backend_package$
上一篇下一篇

猜你喜欢

热点阅读