美文网首页程序员
【Shell Script】带参数

【Shell Script】带参数

作者: Lyudmilalala | 来源:发表于2022-10-27 11:53 被阅读0次

位置参数,带默认值

#!/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$

相关文章

网友评论

    本文标题:【Shell Script】带参数

    本文链接:https://www.haomeiwen.com/subject/ealttdtx.html