Skip to content

Commit

Permalink
Fix usage of calaos commands when container is not running
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulh committed Mar 11, 2024
1 parent dd769a0 commit 534a310
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions env/calaos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,30 @@ export CALAOS_CONFIG="/mnt/calaos/config"
export CALAOS_HAPROXY_TEMPLATE_PATH="/usr/share/calaos-ddns"
export CALAOSDNS_CACHE_DIR="/mnt/calaos/calaos-ddns"

alias calaos_config='podman exec -it calaos-server /opt/bin/calaos_config'
alias calaos_1wire='podman exec -it calaos-server /opt/bin/calaos_1wire'
alias wago_test='podman exec -it calaos-server /opt/bin/wago_test'
alias calaos_mail='podman exec -it calaos-server /opt/bin/calaos_mail'
function calaosserver() {
local cmd
cmd="$1"
shift

#check if calaos-server container is running
if podman ps | grep calaos-server > /dev/null
then
podman exec -it calaos-server ${cmd} "$@"
else
#if not, we need run the container using calaos_1wire instead of calaos_server
local img
img=$(grep IMAGE_SRC /usr/share/calaos/calaos-server.source | cut -d= -f2)
podman run --rm -it \
-v /mnt/calaos/config:/root/.config/calaos \
-v /run/calaos:/run/calaos \
--privileged -v /dev/bus/usb:/dev/bus/usb \
--entrypoint ${cmd} "$img" "$@"
fi
}

alias calaos_1wire='calaosserver /opt/bin/calaos_1wire'
alias calaos_config='calaosserver /opt/bin/calaos_config'
alias wago_test='calaosserver /opt/bin/wago_test'
alias calaos_mail='calaosserver /opt/bin/calaos_mail'
alias xinput_calibrator='podman exec -it -e DISPLAY=:0 calaos-home xinput_calibrator --output-filename /etc/X11/xorg.conf.d/99-calibration.conf'
alias envoy='podman exec -it -e "ENVOY_CACHE_PATH=/config/cache" envoy /app/bin/envoy'

0 comments on commit 534a310

Please sign in to comment.