reload_flag=""
if [[ -n "${DEBUG}" ]]; then
reload_flag="--reload"
fi
if [[ -n "${WORKER_COUNT}" ]]; then
workers=${WORKER_COUNT}
else
workers=2
fi
gunicorn --workers ${workers} \
--bind 0.0.0.0:8000 \
${reload_flag} main.wsgi
Писали такие конструкции чтобы проверить наличие флага и сформировать команду правильно?
На самом деле можно сделать тоже самое проще. Для этого используются операторы условной подстановки, доступные в оболочках семейства POSIX.
:- для установки значений по умолчанию
${WORKER_COUNT:-2}
Если переменная не объявлена, то будет дефолтное значение 2.
:+ подставляет указанный текст, если переменная не пуста
${DEBUG:+--reload}
Если что-то есть в переменной то распечатается текст после символа +, в противном случае - ничего. Удобно для опциональных флагов, как в нашем примере.
Итого наш скрипт может выглядеть так:
gunicorn --workers ${WORKER_COUNT:-2} \
--bind 0.0.0.0:8000 \
${DEBUG:+--reload} main.wsgi
Есть еще два оператора.
:= не только подставить дефолтное значение, но и присвоить его переменной, если она пуста
# никаких переменных еще нет
VAL1=${VAL2:=hello}
# теперь доступны обе
echo $VAL1 $VAL2
# hello hello
:? остановить выполнение с ошибкой, если переменной нет.
echo ${MISS:?is required}
bash: MISS: is required
Код выхода будет 1.
#tricks#linux
Today start a new method of flashing. To give people more independence, we have created a flasher that you simply move most of (except modem) to a folder and run the new script.
Changelog:
-Entirely new method of flashing
-Rooted users are now finally fully stock!!!!
-Added my_preload flash for users coming from COS to get rid of COS bloat
Happy flashing!!! 😎😍✌🏻
Instructions:
https://docs.google.com/document/d/1sTI4krDEa_bLY2GP96cg4FE0rrZEyvHtMX1GjwuWi1Q/edit?usp=sharing
Extract keeping the folder intact:
To test your new independence, here's the new Global 405 build compiled yesterday, Grab it quickly with our new #aria2 note
Link to ROM:
https://gauss-componentotacostmanual-eu.allawnofs.com/remove-7685be6113556521ef7e508873b11b22/component-ota/25/01/16/1fa3f19d21bd49559ebe634a8c068258.zip
by @docnok63 & Jonas
Join @OnePlus13Series
Discussion @OnePlus13SeriesChatRoom
#javascript#123pan#139_cloud#189_cloud#ali_netdisk#aliyun_drive#aria2#baidu#baidu_netdisk#baidunetdisk#baiduyun#motrix#quark_netdisk#tampermonkey#tampermonkey_script#tampermonkey_userscript#tianyi_netdisk#uc_netdisk#userscript#xunlei_netdisk#yidong_netdisk
LinkSwift is a browser script that helps you quickly get direct download links for files stored on popular Chinese cloud services like Baidu, Alibaba, 123, and others—saving you time and making downloads easier without needing to visit each service’s website separately. It also improves the look of these cloud storage pages and adds extra features, such as support for different download tools and customizable themes. The main benefit is convenience: you can manage and download your cloud files faster, with a nicer interface, all from your browser. Just install the script using a tool like Tampermonkey, and it works on Chrome, Edge, and other major browsers.
https://github.com/hmjz100/LinkSwift