php redirector to download latest iso

This commit is contained in:
Frede Hundewadt 2020-01-24 14:33:30 +01:00
parent b3ed15d0fe
commit 808b25b6a7
No known key found for this signature in database
GPG key ID: 7605992471F3F073
2 changed files with 18 additions and 2 deletions

View file

@ -231,6 +231,12 @@ gen_latest_html(){
html_doc+="<title>Download Redirection</title>"
html_doc+="If you are not redirected automatically, follow the <a href=\"${direct_url}\">link to latest iso</a>"
echo ${html_doc} > "${iso_dir}/.latest"
php_doc="<?php "
php_doc+="header('Location: ' . '${direct_url}', true, 303); "
php_doc+="die(); "
php_doc+="?>"
echo ${php_doc} > "${iso_dir}/.latest.php"
fi
fi
}

View file

@ -80,7 +80,7 @@ sync_dir(){
msg "Start upload [%s] to [%s] ..." "$1" "${project}"
while [[ $count -le $max_count ]]; do
rsync ${rsync_args[*]} --exclude '.latest' ${src_dir}/ ${server}/${target_dir}/
rsync ${rsync_args[*]} --exclude '.latest*' ${src_dir}/ ${server}/${target_dir}/
if [[ $? != 0 ]]; then
count=$(($count + 1))
msg "Upload failed. retrying (%s/%s) ..." "$count" "$max_count"
@ -88,6 +88,7 @@ sync_dir(){
else
count=$(($max_count + 1))
[[ -f "${src_dir}/.latest" ]] && sync_latest_html
[[ -f "${src_dir}/.latest.php" ]] && sync_latest_php
msg "Done upload [%s]" "$1"
show_elapsed_time "${FUNCNAME}" "${timer_start}"
fi
@ -96,10 +97,19 @@ sync_dir(){
}
sync_latest_html(){
msg2 "Sending download link ..."
msg2 "Uploading url redirector ..."
local webserver=$(connect_webserver)
local htdocs="htdocs/${profile}"
local html="latest"
scp "${src_dir}/.${html}" "${webserver}/${htdocs}/${html}"
rm -f "${src_dir}/.${html}"
}
sync_latest_php(){
msg2 "Uploading php redirector ..."
local webserver=$(connect_webserver)
local htdocs="htdocs/${profile}"
local php="latest.php"
scp "${src_dir}/.${php}" "${webserver}/${htdocs}/${php}"
rm -f "${src_dir}/.${php}"
}