mirror of
https://memleak.eu/sn0w/pleroma-docker.git
synced 2024-12-22 01:58:49 -05:00
Add new helper methods
This commit is contained in:
parent
3c512c7788
commit
074ea0ef8f
35
pleroma
35
pleroma
@ -17,6 +17,20 @@ flags=""
|
|||||||
# Helpers #
|
# Helpers #
|
||||||
#########################################################
|
#########################################################
|
||||||
|
|
||||||
|
has_command() {
|
||||||
|
if command -v 1>/dev/null 2>&1 "$1"; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
require_command() {
|
||||||
|
if ! has_command "$1"; then
|
||||||
|
printf "\nError: This action requires the command '%s' in your PATH.\n" "$1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
render_template() {
|
render_template() {
|
||||||
m4 $flags docker-compose.m4 | awk 'NF'
|
m4 $flags docker-compose.m4 | awk 'NF'
|
||||||
}
|
}
|
||||||
@ -45,6 +59,27 @@ load_env() {
|
|||||||
done < .env
|
done < .env
|
||||||
}
|
}
|
||||||
|
|
||||||
|
download_file() { # $1: source, $2: target
|
||||||
|
if has_command curl; then
|
||||||
|
curl -sSL "$1" -o "$2"
|
||||||
|
elif has_command wget; then
|
||||||
|
wget "$1" -O "$2"
|
||||||
|
else
|
||||||
|
printf "\nError: This action requires either curl or wget in your PATH.\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
request_file_content() { # $1: source
|
||||||
|
if has_command curl; then
|
||||||
|
curl -sSL "$1"
|
||||||
|
elif has_command wget; then
|
||||||
|
wget "$1" -O- 2>/dev/null
|
||||||
|
else
|
||||||
|
printf "\nError: This action requires either curl or wget in your PATH.\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
#########################################################
|
#########################################################
|
||||||
# Subcommands #
|
# Subcommands #
|
||||||
#########################################################
|
#########################################################
|
||||||
|
Loading…
Reference in New Issue
Block a user