Commit 18e8a3dc authored by nimrod's avatar nimrod
Browse files

A bunch of tweaks for working in a Toolbox container.

- Replace the bfg shell alias with a script, use the jar in the Docker
  image if available.
- Use full Docker image names for use with Podman.
- Remove kpcli and keybase aliases, not in use anymore.
- In the notify script, get the host' hostname if in a Toolbox
  container.
- Script to update the workbench container.
parent 7382af0e
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ alias ansible-local-playbook='ansible-playbook -i localhost, -c local -e "ansibl
alias ansible-local='ansible localhost -c local -i localhost, -e "ansible_python_interpreter=$(which python3)"'
alias aptitude='aptitude --display-format %p --quiet'
alias bell="printf '\\a'"
alias bfg='java -jar $HOME/.local/share/bfg/bfg.jar'
alias black='black --line-length 79'
alias blue="printf '\e[1;94m%s\e[0m\n'"
alias bold="printf '\e[1m%s\e[0m\n'"
@@ -92,12 +91,10 @@ alias gcc='gcc --std=c99 -Wall -Wextra -Werror -pedantic'
alias gen-mac='hexdump -n5 -e '\''"02" 5/1 ":%02X" "\n"'\'' /dev/urandom'
alias gen-ssh-config="rc_make .ssh/config"
alias green="printf '\e[1;92m%s\e[0m\n'"
alias hostlocal='docker run --rm --privileged --net=host gliderlabs/hostlocal'
alias hostlocal='docker run --rm --privileged --net=host docker.io/gliderlabs/hostlocal'
alias http-server='python3 -m http.server 8080'
alias httpbin='gunicorn httpbin:app --bind 0.0.0.0:8080'
alias jjb='jenkins-jobs'
alias killkeybase='pgrep --full keybase | xargs -rt kill'
alias kpcli='kpcli --kdb ~/Documents/Database.kdbx'
alias l='ls -F'
alias la='ls -AF'
alias listen_tcp='nc -vlk 0.0.0.0'
@@ -124,8 +121,13 @@ alias netdata='docker run --detach \
                          --volume /var/run/docker.sock:/var/run/docker.sock \
                          --publish 19999:19999 \
                          --security-opt apparmor=unconfined \
                          netdata/netdata'
alias newman='docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/etc/newman" -t postman/newman_alpine33'
                          docker.io/netdata/netdata'
# shellcheck disable=SC1004
alias newman='docker run --rm \
                         -u "$(id -u):$(id -g)" \
                         -v "$PWD:/etc/newman" \
                         -t \
                         docker.io/postman/newman_alpine33'
alias nextcloudcmd='flatpak run --command=nextcloudcmd com.nextcloud.desktopclient.nextcloud'
# shellcheck disable=SC2139
alias notify="notify --hint \"string:desktop-entry:$(basename "${GIO_LAUNCHED_DESKTOP_FILE:-io.elementary.terminal.desktop}")\""

Documents/bin/bfg

0 → 100755
+13 −0
Original line number Diff line number Diff line
#!/bin/sh
set -eu

if [ -f /usr/local/share/bfg/bfg.jar ]
then
    exec java -jar /usr/local/share/bfg/bfg.jar "$@"
elif [ -f "${XDG_DATA_HOME:-$HOME/.local/share}/bfg/bfg.jar" ]
then
    exec java "${XDG_DATA_HOME:-$HOME/.local/share}/bfg/bfg.jar" "$@"
else
    echo "Can't find the BFG jar, exiting." >&2
    exit 1
fi
+6 −1
Original line number Diff line number Diff line
@@ -32,6 +32,12 @@ else
    hostname="$(sysctl -a 2>/dev/null | awk -F '=' '/^kern[a-z]*\.hostname/ {print $2}')"
fi

# Get the host' hostname in case
if [ "$hostname" = 'toolbox' ]
then
    hostname="$(/usr/libexec/flatpak-xdg-utils/flatpak-spawn --host hostname)"
fi

#FIXME: Remove domain, just hostname.

case "$hostname" in
@@ -41,7 +47,6 @@ case "$hostname" in
    kodi) nextcloud;;
    ns1) nextcloud;;
    ns4) nextcloud;;
    workbench) nextcloud;;
    YOGA-C930) notify_send "$@";;
    *) ;;
esac
+28 −0
Original line number Diff line number Diff line
#!/bin/sh
set -eu

IMAGE='registry.shore.co.il/workbench'
CONTAINER='workbench'

is_latest() {
    podman image exists "$IMAGE" || return 1
    toolbox run --container "$CONTAINER" true 2>/dev/null || return 1
    current="$(podman image inspect "$IMAGE" --format '{{.Digest}}')"
    podman image pull --quiet "$IMAGE" > /dev/null
    new="$(podman image inspect "$IMAGE" --format '{{.Digest}}')"
    [ "$new" = "$current" ] || return 1
}

update() {
    toolbox rm --force "$CONTAINER" 2>/dev/null || true
    yes | podman image prune --filter 'label=com.github.containers.toolbox=true'
    toolbox create --image "$IMAGE"
}

if [ "$(hostname)" = 'toolbox' ]
then
    /usr/libexec/flatpak-xdg-utils/flatpak-spawn --host "$0" "$@"
elif ! (is_latest)
then
    update
fi