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
OnePlus Archive
OnePlus Archive is a firmware repository for OnePlus phones offering stock OTA images and full firmware packages. It includes archived files for specific partition images to save bandwidth and storage, along with boot/init_boot images for rooting, un-rooting, flashing stock firmware and aftermarket development purposes.
🔗 Links:
- GitHub repo
Developer: Spike
❤️ Support the Project
If this project makes your life easier, here are a few quick ways to show some love:
⭐ Star the repo/app
☕ Buy a coffee for the developer
🛠 Contribute code, issues, or pull-requests
🏷 Tags: #Android#OnePlus#Firmware
Oneplus Archive
This project provides official, unmodified OnePlus stock firmware images for supported models, ideal for rooting, flashing custom ROM(s) and more
⚙️ Repo Link: Here
👤 Maintainer: Spike & Team
#oneplus#firmware#boot#otaimage#root
#shell#buildroot_external_tree#firmware#ingenic#ip_camera#ipc#ipcamera
Thingino is free, open-source firmware designed specifically for IP cameras using Ingenic SoC chips. It customizes the software to fit each supported camera model, making the camera easier to use and more efficient. You can build the firmware yourself using the provided instructions and tools, and there is a helpful web interface to control camera features like pan, tilt, night mode, and streaming. This gives you more control and flexibility over your camera without relying on proprietary software. It supports many camera models, and the community offers resources like a wiki, chat groups, and development guides to help you get started and customize your device. This benefits you by providing a customizable, transparent, and community-supported alternative to closed camera firmware.
https://github.com/themactep/thingino-firmware