From f2f03d6ea4d6d181880a9f9c4f019d24065db4ec Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Sat, 16 Apr 2022 14:27:42 +0200 Subject: Initial draft for sync subcommand --- lib/util.bash | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'lib/util.bash') diff --git a/lib/util.bash b/lib/util.bash index 2c10ef4..c6ef534 100644 --- a/lib/util.bash +++ b/lib/util.bash @@ -3,7 +3,7 @@ # Change the working directory. In usage, this is the same as using cd, # however, it will make additional checks to ensure everything is going fine. chgdir() { - debug "tyilnet/chgdir" "Changing workdir to $1" + debug "bashtard/chgdir" "Changing workdir to $1" cd -- "$1" || die "Failed to change directory to $1" } @@ -42,7 +42,7 @@ config_for() { if [[ -n $value ]] then - debug "tyilnet/config_for" "Found $key=$value in $file" + debug "bashtard/config_for" "Found $key=$value in $file" printf "%s" "$value" return @@ -57,7 +57,7 @@ config_for() { fi # Error - alert "tyilnet/config_for" "No configuration value for $key" + alert "bashtard/config_for" "No configuration value for $key" } # Create a datetime stamp. This is a wrapper around the date utility, ensuring @@ -87,7 +87,7 @@ die() { do case "$opt" in i) code=$OPTARG ;; - *) alert "tyilnet/die" "Unused argument specified: $opt" ;; + *) alert "bashtard/die" "Unused argument specified: $opt" ;; esac done @@ -106,7 +106,7 @@ fetch_http() { do case "$opt" in o) buffer=$OPTARG ;; - *) alert "tyilnet/fetch_http" "Unused argument specified: $opt" ;; + *) alert "bashtard/fetch_http" "Unused argument specified: $opt" ;; esac done @@ -114,7 +114,7 @@ fetch_http() { [[ -z $buffer ]] && buffer="$(tmpfile)" - notice "tyilnet/fetch_http" "Downloading $1 to $buffer" + notice "bashtard/fetch_http" "Downloading $1 to $buffer" for util in curl wget do @@ -126,7 +126,7 @@ fetch_http() { return $exit_code done - die "tyilnet/fetch_http" "Unable to download file over HTTP!" + die "bashtard/fetch_http" "Unable to download file over HTTP!" } fetch_http_curl() { @@ -162,7 +162,7 @@ join_args() { do case "$opt" in c) IFS="$OPTARG" ;; - *) warn "tyilnet/join_args" "Unused opt specified: $opt" ;; + *) warn "bashtard/join_args" "Unused opt specified: $opt" ;; esac done @@ -173,7 +173,7 @@ join_args() { # OS independent package management pkg() { - local system="tyilnet/pkg" + local system="bashtard/pkg" local action=$1 ; shift local app="$(config "pkg.$1" "$(config "app.$1")")" ; shift @@ -196,7 +196,7 @@ pkg() { } pkg_install() { - local system="tyilnet/pkg/install" + local system="bashtard/pkg/install" local app=$1 ; shift @@ -216,7 +216,7 @@ pkg_install() { # OS independent service management. svc() { - local system="tyilnet/svc" + local system="bashtard/svc" local service local action @@ -240,7 +240,7 @@ svc() { } svc_enable() { - local system="tyilnet/svc/enable" + local system="bashtard/svc/enable" local service=$1 @@ -257,7 +257,7 @@ svc_enable() { } svc_restart() { - local system="tyilnet/svc/restart" + local system="bashtard/svc/restart" local service=$1 @@ -275,7 +275,7 @@ svc_restart() { } svc_start() { - local system="tyilnet/svc/start" + local system="bashtard/svc/start" local service=$1 @@ -299,26 +299,26 @@ template() if [[ ! -f $file ]] then - crit "tyilnet/template" "Tried to render template from $file, but it doesn't exist" + crit "bashtard/template" "Tried to render template from $file, but it doesn't exist" return fi for kv in "$@" do - debug "tyilnet/template" "Adding $kv to sedfile at $sedfile" + debug "bashtard/template" "Adding $kv to sedfile at $sedfile" key="$(awk -F= '{ print $1 }' <<< $kv)" if [[ -z "$key" ]] then - crit "tyilnet/template" "Empty key in '$kv' while rendering $file?" + crit "bashtard/template" "Empty key in '$kv' while rendering $file?" fi value="$(awk -F= '{ print $NF }' <<< $kv)" if [[ -z "$value" ]] then - crit "tyilnet/template" "Empty key in '$kv' while rendering $file?" + crit "bashtard/template" "Empty key in '$kv' while rendering $file?" fi printf 's@${%s}@%s@g\n' "$key" "$value" >> "$sedfile" @@ -337,10 +337,10 @@ tmpdir() { # Ensure the file was created succesfully if [[ ! -d "$dir" ]] then - die "tyilnet/tmpdir" "Failed to create a temporary directory at $dir" + die "bashtard/tmpdir" "Failed to create a temporary directory at $dir" fi - debug "tyilnet/tmpdir" "Temporary file created at $dir" + debug "bashtard/tmpdir" "Temporary file created at $dir" printf "%s" "$dir" } @@ -356,10 +356,10 @@ tmpfile() { # Ensure the file was created succesfully if [[ ! -f "$file" ]] then - die "tyilnet/tmpfile" "Failed to create a temporary file at $file" + die "bashtard/tmpfile" "Failed to create a temporary file at $file" fi - debug "tyilnet/tmpfile" "Temporary file created at $file" + debug "bashtard/tmpfile" "Temporary file created at $file" printf "%s" "$file" } -- cgit v1.1