github.com/canonical/ubuntu-image@v0.0.0-20240430122802-2202fe98b290/tests/lib/external/snapd-testing-tools/tools/os.paths (about) 1 #!/bin/bash 2 3 show_help() { 4 echo "usage: os.paths snap-mount-dir, media-dir, libexec-dir" 5 echo "" 6 echo "get paths information for the current system" 7 } 8 9 snap_mount_dir() { 10 if os.query is-fedora || os.query is-amazon-linux || os.query is-centos || os.query is-arch-linux; then 11 echo "/var/lib/snapd/snap" 12 else 13 echo "/snap" 14 fi 15 } 16 17 media_dir() { 18 if os.query is-fedora || os.query is-amazon-linux || os.query is-centos || os.query is-arch-linux || os.query is-opensuse; then 19 echo "/run/media" 20 else 21 echo "/media" 22 fi 23 } 24 25 libexec_dir() { 26 if os.query is-fedora || os.query is-amazon-linux || os.query is-centos || os.query is-opensuse tumbleweed; then 27 echo "/usr/libexec" 28 else 29 echo "/usr/lib" 30 fi 31 } 32 33 main() { 34 if [ $# -eq 0 ]; then 35 show_help 36 exit 0 37 fi 38 39 local subcommand="$1" 40 local action= 41 while [ $# -gt 0 ]; do 42 case "$1" in 43 -h|--help) 44 show_help 45 exit 0 46 ;; 47 *) 48 action=$(echo "$subcommand" | tr '-' '_') 49 shift 50 break 51 ;; 52 esac 53 done 54 55 if [ -z "$(declare -f "$action")" ]; then 56 echo "os.paths: unknown path $subcommand" >&2 57 show_help 58 exit 1 59 fi 60 61 "$action" "$@" 62 } 63 64 main "$@"