-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
snapcraft/hooks: Share common functions among hooks
Signed-off-by: Max Asnaashari <[email protected]>
- Loading branch information
Showing
3 changed files
with
14 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,13 @@ | ||
#!/bin/sh | ||
|
||
# Utility functions | ||
get_bool() { | ||
value=$(echo "${1:-}" | tr '[:upper:]' '[:lower:]') | ||
set -eu | ||
|
||
# See if it's true | ||
for yes in "true" "1" "yes" "on"; do | ||
if [ "${value}" = "${yes}" ]; then | ||
echo "true" | ||
return | ||
fi | ||
done | ||
SNAP_CURRENT="$(realpath "${SNAP}/..")/current" | ||
export "${SNAP_CURRENT}" | ||
|
||
# See if it's false | ||
for no in "false" "0" "no" "off"; do | ||
if [ "${value}" = "${no}" ]; then | ||
echo "false" | ||
return | ||
fi | ||
done | ||
|
||
# Invalid value (or not set) | ||
return | ||
} | ||
. "${SNAP_CURRENT}/snap/hooks/common" | ||
|
||
ceph_builtin=$(get_bool "$(snapctl get ceph.builtin)") | ||
|
||
if ! [ "${ceph_builtin:-"false"}" = "true" ]; then | ||
ln -snf ${SNAP_DATA}/microceph/conf/ /etc/ceph | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters