various
parent
406f791c89
commit
3a3a4dddcf
|
@ -44,6 +44,7 @@
|
||||||
!/usr/local/bin/
|
!/usr/local/bin/
|
||||||
/usr/local/bin/*
|
/usr/local/bin/*
|
||||||
!/usr/local/bin/sh.zio.backup
|
!/usr/local/bin/sh.zio.backup
|
||||||
|
!/usr/local/bin/sh.zio.install-package
|
||||||
!/usr/local/bin/sh.zio.pod-exec
|
!/usr/local/bin/sh.zio.pod-exec
|
||||||
!/usr/local/bin/zio-backup
|
!/usr/local/bin/zio-backup
|
||||||
!/usr/local/bin/zio-libvirt-port-forward
|
!/usr/local/bin/zio-libvirt-port-forward
|
||||||
|
|
|
@ -19,7 +19,7 @@ function download_restic() {
|
||||||
restic_version="$1"
|
restic_version="$1"
|
||||||
|
|
||||||
restic_download_url="https://github.com/restic/restic/releases/download/v${restic_version}/restic_${restic_version}_linux_amd64.bz2"
|
restic_download_url="https://github.com/restic/restic/releases/download/v${restic_version}/restic_${restic_version}_linux_amd64.bz2"
|
||||||
restic_path="/tmp/restic-$restic_version"
|
restic_path="/tmp/restic-v$restic_version"
|
||||||
restic_archive_path="${restic_path}_$(date +%s).${restic_download_url##*.}"
|
restic_archive_path="${restic_path}_$(date +%s).${restic_download_url##*.}"
|
||||||
|
|
||||||
if [[ ! -f "$restic_path" ]]; then
|
if [[ ! -f "$restic_path" ]]; then
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [[ "$(realpath "$(dirname "$(realpath -s "$0")")/../../../")" == "/" ]]; then
|
||||||
|
. /usr/local/libexec/zio/helpers/bash.sh
|
||||||
|
else
|
||||||
|
. "$(dirname "$(realpath -s "$0")")/../libexec/zio/helpers/bash.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
requested_package="$1"
|
||||||
|
tmp_path_hash="$(date +%s)"
|
||||||
|
|
||||||
|
function get_install_path() {
|
||||||
|
install_path="/usr/local/bin/$1"
|
||||||
|
|
||||||
|
if [[ -f "$install_path" ]] && [[ "$(file "$install_path")" != *": empty" ]]; then
|
||||||
|
chmod +x "$install_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$install_path"
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_name() {
|
||||||
|
package_id="$1"
|
||||||
|
package_name=""
|
||||||
|
|
||||||
|
case $package_id in
|
||||||
|
"caddy") package_name="Caddy" ;;
|
||||||
|
*) package_name="$package_id" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "$package_name"
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_tmp_path() {
|
||||||
|
tmp_path="/tmp/$1_${tmp_path_hash}"
|
||||||
|
|
||||||
|
if [[ -f "$tmp_path" ]] && [[ "$(file "$tmp_path")" != *": empty" ]]; then
|
||||||
|
chmod +x "$tmp_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$tmp_path"
|
||||||
|
}
|
||||||
|
|
||||||
|
function download() {
|
||||||
|
package_id="$1"
|
||||||
|
url="$2"
|
||||||
|
|
||||||
|
package_name="$(get_name "$package_id")"
|
||||||
|
package_tmp_path="$(get_tmp_path "$package_id")"
|
||||||
|
|
||||||
|
say info "Downloading: $package_name ($package_tmp_path)"
|
||||||
|
wget "$url" -O "$(get_tmp_path "$package_id")"
|
||||||
|
}
|
||||||
|
|
||||||
|
function install() {
|
||||||
|
package_id="$1"
|
||||||
|
package_version="$2"
|
||||||
|
|
||||||
|
package_name="$(get_name "$package_id")"
|
||||||
|
|
||||||
|
if [[ -z "$package_version" ]]; then
|
||||||
|
say info "Installing: $package_name ($(get_install_path "$package_id"))"
|
||||||
|
mv "$(get_tmp_path "$package_id")" "$(get_install_path "$package_id")"
|
||||||
|
else
|
||||||
|
if [[ "$package_version" != "v"* ]]; then
|
||||||
|
package_version="v$package_version"
|
||||||
|
fi
|
||||||
|
|
||||||
|
package_id_version="$package_id-$package_version"
|
||||||
|
|
||||||
|
say info "Installing: $package_name $package_version ($(get_install_path "$package_id_version"))"
|
||||||
|
rm -f "$(get_install_path "$package_id")"
|
||||||
|
mv "$(get_tmp_path "$package_id")" "$(get_install_path "$package_id_version")"
|
||||||
|
|
||||||
|
say info "Symlinking: $(get_install_path "$package_id_version") ➔ $(get_install_path "$package_id")"
|
||||||
|
ln -s "$(get_install_path "$package_id_version")" "$(get_install_path "$package_id")"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function download_caddy() {
|
||||||
|
package_id="caddy"
|
||||||
|
|
||||||
|
download "caddy" "https://caddyserver.com/api/download?os=linux&arch=amd64&p=github.com%2Fcaddy-dns%2Fcloudflare"
|
||||||
|
|
||||||
|
caddy_version="$($(get_tmp_path "$package_id") version)"
|
||||||
|
caddy_version_array=($caddy_version)
|
||||||
|
caddy_version="${caddy_version_array[0]}"
|
||||||
|
|
||||||
|
install "$package_id" "$caddy_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
function download_generic() {
|
||||||
|
package_id="$requested_package"
|
||||||
|
download "$requested_package" "$1"
|
||||||
|
install "$requested_package"
|
||||||
|
}
|
||||||
|
|
||||||
|
case $requested_package in
|
||||||
|
"caddy") download_caddy ;;
|
||||||
|
*) die "Package '$requested_package' cannot be installed by this tool" ;;
|
||||||
|
esac
|
Loading…
Reference in New Issue