autostart-manage/autoinstall/file_command.sh

34 lines
506 B
Bash
Raw Permalink Normal View History

2024-01-09 15:48:11 +00:00
#!/usr/bin/env bash
pipe=${args[--pipe]:?}
target=${args[target]:?}
url=${args[url]:?}
if [ "${action:-file}" = "exe" ]
then
if [ -x "$(command -v "$target")" ]
then
return
fi
target="$HOME/.local/bin/$target"
fi
if [ ! -f "$target" ]
then
echo "Installing file $url to $target"
target_dir=$(dirname "$target")
mkdir -p "$target_dir"
cd "$target_dir" || exit 1
_http_client "$url" | eval "$pipe" > "$target"
if [ "${action:-file}" = "exe" ]
then
chmod +x "$target"
fi
_run_hook
fi