fix forgejo uploader
This commit is contained in:
parent
f3e03bba8c
commit
bda07dd821
1 changed files with 27 additions and 18 deletions
|
|
@ -9,6 +9,18 @@ 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_cursor() {
|
||||||
|
tput cnorm
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
hide_cursor() {
|
||||||
|
tput civis
|
||||||
|
}
|
||||||
|
|
||||||
|
trap show_cursor INT TERM
|
||||||
|
hide_cursor
|
||||||
|
|
||||||
## check for config file
|
## check for config file
|
||||||
if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg" ]]; then
|
if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg" ]]; then
|
||||||
configfile="${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg"
|
configfile="${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg"
|
||||||
|
|
@ -24,8 +36,7 @@ EOF
|
||||||
echo -e "\b$color_note example configuration created at"
|
echo -e "\b$color_note example configuration created at"
|
||||||
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
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# secure the config file
|
# secure the config file
|
||||||
|
|
@ -38,25 +49,12 @@ while IFS= read -r line; do
|
||||||
done <<EOF
|
done <<EOF
|
||||||
$(cat "$configfile" | grep -v "^$")
|
$(cat "$configfile" | grep -v "^$")
|
||||||
EOF
|
EOF
|
||||||
# now source it, either the original or the filtered variant
|
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source "$configfile"
|
source "$configfile"
|
||||||
|
|
||||||
show_cursor() {
|
|
||||||
tput cnorm
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
|
|
||||||
hide_cursor() {
|
|
||||||
tput civis
|
|
||||||
}
|
|
||||||
|
|
||||||
trap show_cursor INT TERM
|
|
||||||
hide_cursor
|
|
||||||
|
|
||||||
show_progress() {
|
show_progress() {
|
||||||
pid=$1
|
pid=$1
|
||||||
spin='-\|/'
|
spin='—\|/'
|
||||||
i=0
|
i=0
|
||||||
while kill -0 "$pid" 2>/dev/null; do
|
while kill -0 "$pid" 2>/dev/null; do
|
||||||
i=$(((i + 1) % 4))
|
i=$(((i + 1) % 4))
|
||||||
|
|
@ -65,11 +63,22 @@ show_progress() {
|
||||||
sleep .1
|
sleep .1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
check_for_pkg() {
|
||||||
|
pkg=$(find ./ -type f -name "*.pkg.tar.zst")
|
||||||
|
if [ ! -z "$pkg" ]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo -e "\b$color_error no packges found."
|
||||||
|
echo -e "\b\tPlease run this script from inside the directory"
|
||||||
|
echo -e "\b\twhich holds the Arch-packages."
|
||||||
|
echo -e "\b$color_ok Exiting now."
|
||||||
|
show_cursor
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
upload_package() {
|
upload_package() {
|
||||||
for file in ./*; do
|
for file in ./*; do
|
||||||
if [[ "$file" != *.pkg.tar.zst ]]; then
|
if [[ "$file" != *.pkg.tar.zst ]]; then
|
||||||
echo -e "\b$color_error No arch packages found"
|
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo -e "\b$color_note uploading $file"
|
echo -e "\b$color_note uploading $file"
|
||||||
|
|
@ -82,6 +91,6 @@ upload_package() {
|
||||||
done
|
done
|
||||||
echo -e "\b$color_ok packges uploaded"
|
echo -e "\b$color_ok packges uploaded"
|
||||||
}
|
}
|
||||||
|
check_for_pkg
|
||||||
upload_package & show_progress $!
|
upload_package & show_progress $!
|
||||||
show_cursor
|
show_cursor
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue