@@ -22,22 +22,24 @@ config_overridden=false
2222
2323show_help_and_exit () {
2424 echo ' Supported arguments:'
25- echo ' -c PATH Provide custom config for toninstaller.sh'
26- echo ' -t Disable telemetry'
27- echo ' -i Ignore minimum requirements'
28- echo ' -d Use pre-packaged dump. Reduces duration of initial synchronization.'
29- echo ' -a Set MyTonCtrl git repo author'
30- echo ' -r Set MyTonCtrl git repo'
31- echo ' -b Set MyTonCtrl git repo branch'
32- echo ' -g URL TON node git repo URL (default: https://github.com/ton-blockchain/ton.git)'
33- echo ' -m MODE Install MyTonCtrl with specified mode (validator or liteserver)'
34- echo ' -n NETWORK Specify the network (mainnet or testnet)'
35- echo ' -v VERSION Specify the ton node version (commit, branch, or tag)'
36- echo ' -u USER Specify the user to be used for MyTonCtrl installation'
37- echo ' -p PATH Provide backup file for MyTonCtrl installation'
38- echo ' -o Install only MyTonCtrl. Must be used with -p'
39- echo ' -l Install only TON node'
40- echo ' -h Show this help'
25+ echo ' -c, --config URL Provide custom network config'
26+ echo ' -e, --env-file PATH Provide env file with installation parameters'
27+ echo ' --print-env Print result command and envs after interactive installer without installing MyTonCtrl'
28+ echo ' -t, --telemetry Disable telemetry'
29+ echo ' -i, --ignore-reqs Ignore minimum requirements'
30+ echo ' -d, --dump Use pre-packaged dump. Reduces duration of initial synchronization'
31+ echo ' -a, --author Set MyTonCtrl git repo author'
32+ echo ' -r, --repo Set MyTonCtrl git repo name'
33+ echo ' -b, --branch Set MyTonCtrl git repo branch'
34+ echo ' -m, --mode MODE Install MyTonCtrl with specified mode (validator or liteserver). Leave empty to launch interactive installer'
35+ echo ' -n, --network NETWORK Specify the network (mainnet or testnet)'
36+ echo ' -g, --node-repo URL TON node git repo URL (default: https://github.com/ton-blockchain/ton.git)'
37+ echo ' -v, --node-version VERSION Specify the TON node version (commit, branch, or tag)'
38+ echo ' -u, --user USER Specify the user to be used for MyTonCtrl installation'
39+ echo ' -p, --backup PATH Provide backup file for MyTonCtrl installation'
40+ echo ' -o, --only-mtc Install only MyTonCtrl. Must be used with -p'
41+ echo ' -l, --only-node Install only TON node'
42+ echo ' -h, --help Show this help'
4143 exit
4244}
4345
4749
4850# node install parameters
4951config=" https://ton-blockchain.github.io/global.config.json"
52+ env_file=" "
5053telemetry=true
5154ignore=false
5255dump=false
@@ -57,7 +60,58 @@ mode=none
5760cpu_required=16
5861mem_required=64000000 # 64GB in KB
5962
60- while getopts " :c:tidola:r:b:m:n:v:u:p:g:h" flag; do
63+ # transform --long options to short, because getopts only supports short ones
64+
65+ newargv=()
66+ while (( $# )) ; do
67+ case " $1 " in
68+ --) # end of options
69+ shift
70+ newargv+=( -- " $@ " )
71+ break
72+ ;;
73+
74+ # no arg
75+ --dump) newargv+=(-d) ;;
76+ --only-mtc) newargv+=(-o) ;;
77+ --only-node) newargv+=(-l) ;;
78+ --help) newargv+=(-h) ;;
79+ --telemetry) newargv+=(-t) ;;
80+ --ignore-reqs) newargv+=(-i) ;;
81+ --print-env) export PRINT_ENV=true ;;
82+
83+ # with arg
84+ --config|--author|--repo|--branch|--mode|--network|--node-repo|--backup|--user|--node-version|--env-file)
85+ if (( $# < 2 )) ; then
86+ echo " Error: option $1 requires value" >&2 ; exit 2
87+ fi
88+ case " $1 " in
89+ --config) newargv+=(-c " $2 " ) ;;
90+ --author) newargv+=(-a " $2 " ) ;;
91+ --repo) newargv+=(-r " $2 " ) ;;
92+ --branch) newargv+=(-b " $2 " ) ;;
93+ --mode) newargv+=(-m " $2 " ) ;;
94+ --network) newargv+=(-n " $2 " ) ;;
95+ --node-repo) newargv+=(-g " $2 " ) ;;
96+ --backup) newargv+=(-p " $2 " ) ;;
97+ --user) newargv+=(-u " $2 " ) ;;
98+ --node-version) newargv+=(-v " $2 " ) ;;
99+ --env-file) newargv+=(-e " $2 " ) ;;
100+ esac
101+ shift ;;
102+ --* )
103+ echo " Error: unknown option '$1 '" >&2 ; exit 2 ;;
104+ * )
105+ newargv+=(" $1 " ) ;;
106+ esac
107+ shift
108+ done
109+
110+ # printf ' %q' "${newargv[@]}"
111+ # printf '\n'
112+ set -- " ${newargv[@]} "
113+
114+ while getopts " :c:tidola:r:b:m:n:v:u:p:g:e:h" flag; do
61115 case " ${flag} " in
62116 c) config=${OPTARG} ; config_overridden=true;;
63117 t) telemetry=false;;
@@ -74,13 +128,23 @@ while getopts ":c:tidola:r:b:m:n:v:u:p:g:h" flag; do
74128 o) only_mtc=true;;
75129 l) only_node=true;;
76130 p) backup=${OPTARG} ;;
131+ e) env_file=${OPTARG} ;;
77132 h) show_help_and_exit;;
78133 * )
79134 echo " Flag -${flag} is not recognized. Aborting"
80135 exit 1 ;;
81136 esac
82137done
83138
139+ if [ -n " $env_file " ]; then
140+ if [ ! -f " $env_file " ]; then
141+ echo " Env file not found, aborting."
142+ exit 1
143+ fi
144+ set -a
145+ source " $env_file "
146+ set +a
147+ fi
84148
85149if [ " $only_mtc " = true ] && [ " $backup " = " none" ]; then
86150 echo " Backup file must be provided if only mtc installation"
0 commit comments