Update tools.func

This commit is contained in:
CanbiZ 2025-07-09 13:14:00 +02:00
parent d26ca65397
commit 9953026207

View File

@ -449,7 +449,7 @@ function setup_php() {
$STD apt-get install -y apache2 $STD apt-get install -y apache2
$STD systemctl restart apache2 || true $STD systemctl restart apache2 || true
fi fi
if [[ "$PHP_APACHE" == "YES" ]] && [[ -n "$CURRENT_PHP" ]]; then if [[ "$PHP_APACHE" == "YES" ]] && [[ -n "$CURRENT_PHP" ]]; then
if [[ -f /etc/apache2/mods-enabled/php${CURRENT_PHP}.load ]]; then if [[ -f /etc/apache2/mods-enabled/php${CURRENT_PHP}.load ]]; then
$STD a2dismod php${CURRENT_PHP} || true $STD a2dismod php${CURRENT_PHP} || true
@ -914,7 +914,7 @@ function fetch_and_deploy_gh_release() {
} }
} }
### Prebuild Mode ### ### Prebuild Mode ###
elif [[ "$mode" == "prebuild" ]]; then elif [[ "$mode" == "prebuild" ]]; then
local pattern="${6%\"}" local pattern="${6%\"}"
pattern="${pattern#\"}" pattern="${pattern#\"}"
@ -933,7 +933,6 @@ function fetch_and_deploy_gh_release() {
break break
;; ;;
esac esac
done done
[[ -z "$asset_url" ]] && { [[ -z "$asset_url" ]] && {
@ -949,39 +948,42 @@ function fetch_and_deploy_gh_release() {
return 1 return 1
} }
local unpack_tmp
unpack_tmp=$(mktemp -d)
mkdir -p "$target" mkdir -p "$target"
if [[ "$filename" == *.zip ]]; then if [[ "$filename" == *.zip ]]; then
if ! command -v unzip &>/dev/null; then if ! command -v unzip &>/dev/null; then
$STD apt-get install -y unzip $STD apt-get install -y unzip
fi fi
unzip -q "$tmpdir/$filename" -d "$unpack_tmp"
local top_level_entries
top_level_entries=$(unzip -l "$tmpdir/$filename" | awk '{print $4}' | grep -v '^$' | cut -d/ -f1 | sort -u)
if [[ $(wc -l <<<"$top_level_entries") -eq 1 ]]; then
unzip -q "$tmpdir/$filename" -d "$tmpdir/unzip"
shopt -s dotglob nullglob
cp -r "$tmpdir/unzip/"* "$target/"
shopt -u dotglob nullglob
else
unzip -q "$tmpdir/$filename" -d "$target"
fi
elif [[ "$filename" == *.tar.* ]]; then elif [[ "$filename" == *.tar.* ]]; then
local top_level_entries tar -xf "$tmpdir/$filename" -C "$unpack_tmp"
top_level_entries=$(tar -tf "$tmpdir/$filename" | cut -d/ -f1 | sort -u)
if [[ $(wc -l <<<"$top_level_entries") -eq 1 ]]; then
tar --strip-components=1 -xf "$tmpdir/$filename" -C "$target"
else
tar -xf "$tmpdir/$filename" -C "$target"
fi
else else
msg_error "Unsupported archive format: $filename" msg_error "Unsupported archive format: $filename"
rm -rf "$tmpdir" rm -rf "$tmpdir" "$unpack_tmp"
return 1 return 1
fi fi
local top_dirs
top_dirs=$(find "$unpack_tmp" -mindepth 1 -maxdepth 1 -type d | wc -l)
if [[ "$top_dirs" -eq 1 ]]; then
# Strip leading folder
local inner_dir
inner_dir=$(find "$unpack_tmp" -mindepth 1 -maxdepth 1 -type d)
shopt -s dotglob nullglob
cp -r "$inner_dir"/* "$target/"
shopt -u dotglob nullglob
else
# Copy all contents
shopt -s dotglob nullglob
cp -r "$unpack_tmp"/* "$target/"
shopt -u dotglob nullglob
fi
rm -rf "$unpack_tmp"
### Singlefile Mode ### ### Singlefile Mode ###
elif [[ "$mode" == "singlefile" ]]; then elif [[ "$mode" == "singlefile" ]]; then
local pattern="${6%\"}" local pattern="${6%\"}"