fix upload skripts

This commit is contained in:
Christian Schendel 2025-09-16 21:23:31 +02:00
parent 80fe44716a
commit 81ed0781d9
Signed by: doppelhelix
GPG key ID: 5874D2437CD5BBB3
2 changed files with 37 additions and 34 deletions

View file

@ -9,10 +9,20 @@ color_ok="\e[1;32m==>\e[0m"
color_error="\e[1;31m==>\e[0m" color_error="\e[1;31m==>\e[0m"
color_warning="\e[1;35m==>\e[0m" color_warning="\e[1;35m==>\e[0m"
show_progress() {
pid=$1
spin='—\|/'
i=0
while kill -0 "$pid" 2>/dev/null; do
i=$(((i + 1) % 4))
spinner="${spin:$i:1}"
printf '\b%s' "$spinner"
sleep .1
done
}
show_cursor() { show_cursor() {
tput cnorm tput cnorm
exit 1
} }
hide_cursor() { hide_cursor() {
@ -22,7 +32,6 @@ hide_cursor() {
trap show_cursor INT TERM trap show_cursor INT TERM
hide_cursor hide_cursor
configfile="${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-3rdparty-repo.cfg" configfile="${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-3rdparty-repo.cfg"
## check for config file ## check for config file
@ -40,6 +49,7 @@ EOF
echo -e "\b$color_note ${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg" echo -e "\b$color_note ${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg"
echo -e "\b$color_warning please edit it before running this script again" echo -e "\b$color_warning please edit it before running this script again"
show_cursor show_cursor
exit
fi fi
# secure the config file # secure the config file
@ -55,20 +65,9 @@ EOF
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "$configfile" source "$configfile"
show_progress() {
pid=$1
spin='—\|/'
i=0
while kill -0 "$pid" 2>/dev/null; do
i=$(((i + 1) % 4))
spinner="${spin:$i:1}"
printf '\b%s' "$spinner"
sleep .1
done
}
check_for_pkg() { check_for_pkg() {
pkg=$(find ./ -type f -name "*.pkg.tar.zst") mapfile -t pkg < <(find ./ -maxdepth 1 -name "*.pkg.tar.zst")
if [ ! -z "$pkg" ]; then if [ ${#pkg[@]} -gt 0 ]; then
: :
else else
echo -e "\b$color_error no packges found." echo -e "\b$color_error no packges found."
@ -76,6 +75,7 @@ check_for_pkg() {
echo -e "\b\twhich holds the Arch-packages." echo -e "\b\twhich holds the Arch-packages."
echo -e "\b$color_ok Exiting now." echo -e "\b$color_ok Exiting now."
show_cursor show_cursor
exit
fi fi
} }
@ -92,8 +92,8 @@ upload_package() {
--data-binary "@$file" --data-binary "@$file"
fi fi
done done
echo -e "\n\b$color_ok packges uploaded"
} }
check_for_pkg check_for_pkg
upload_package & show_progress $! upload_package & show_progress $!
echo -e "\b$color_ok Done!"
show_cursor show_cursor

View file

@ -9,9 +9,20 @@ color_ok="\e[1;32m==>\e[0m"
color_error="\e[1;31m==>\e[0m" color_error="\e[1;31m==>\e[0m"
color_warning="\e[1;35m==>\e[0m" color_warning="\e[1;35m==>\e[0m"
show_progress() {
pid=$1
spin='—\|/'
i=0
while kill -0 "$pid" 2>/dev/null; do
i=$(((i + 1) % 4))
spinner="${spin:$i:1}"
printf '\b%s' "$spinner"
sleep .1
done
}
show_cursor() { show_cursor() {
tput cnorm tput cnorm
exit 1
} }
hide_cursor() { hide_cursor() {
@ -21,13 +32,14 @@ hide_cursor() {
trap show_cursor INT TERM trap show_cursor INT TERM
hide_cursor hide_cursor
configfile="${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg"
## check for config file ## check for config file
if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg" ]]; then if [[ -r "$configfile" ]]; then
configfile="${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg"
configfile_secured="${TMPDIR:-/tmp}/tmp.upload-to-dalci-repo.cfg" configfile_secured="${TMPDIR:-/tmp}/tmp.upload-to-dalci-repo.cfg"
else else
echo -e "\b$color_error no configuration found" echo -e "\b$color_error no configuration found"
cat > "${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg" << EOF cat > "$configfile" << EOF
forgejo_repo_url="https://{domain}/api/packages/{owner}/arch/{group}" forgejo_repo_url="https://{domain}/api/packages/{owner}/arch/{group}"
forgejo_user="your_username" forgejo_user="your_username"
forgejo_token="your_token_or_password" forgejo_token="your_token_or_password"
@ -37,6 +49,7 @@ EOF
echo -e "\b$color_note ${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg" echo -e "\b$color_note ${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg"
echo -e "\b$color_warning please edit it before running this script again" echo -e "\b$color_warning please edit it before running this script again"
show_cursor show_cursor
exit
fi fi
# secure the config file # secure the config file
@ -52,20 +65,9 @@ EOF
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "$configfile" source "$configfile"
show_progress() {
pid=$1
spin='—\|/'
i=0
while kill -0 "$pid" 2>/dev/null; do
i=$(((i + 1) % 4))
spinner="${spin:$i:1}"
printf '\b%s' "$spinner"
sleep .1
done
}
check_for_pkg() { check_for_pkg() {
pkg=$(find ./ -type f -name "*.pkg.tar.zst") mapfile -t pkg < <(find ./ -maxdepth 1 -name "*.pkg.tar.zst")
if [ ! -z "$pkg" ]; then if [ ${#pkg[@]} -gt 0 ]; then
: :
else else
echo -e "\b$color_error no packges found." echo -e "\b$color_error no packges found."
@ -73,6 +75,7 @@ check_for_pkg() {
echo -e "\b\twhich holds the Arch-packages." echo -e "\b\twhich holds the Arch-packages."
echo -e "\b$color_ok Exiting now." echo -e "\b$color_ok Exiting now."
show_cursor show_cursor
exit
fi fi
} }
@ -89,8 +92,8 @@ upload_package() {
--data-binary "@$file" --data-binary "@$file"
fi fi
done done
echo -e "\n\b$color_ok packges uploaded"
} }
check_for_pkg check_for_pkg
upload_package & show_progress $! upload_package & show_progress $!
echo -e "\b$color_ok Done!"
show_cursor show_cursor