forked from mirrored-repos/manjaro-tools
Merge branch 'more_latest_links' into 'master'
more perma links See merge request tools/development-tools/manjaro-tools!308
This commit is contained in:
commit
b4038736dd
2 changed files with 81 additions and 18 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
.idea
|
||||||
*~
|
*~
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
*.tar.xz
|
*.tar.xz
|
||||||
|
|
|
@ -15,16 +15,17 @@ connect(){
|
||||||
echo "${account}${storage}${project}"
|
echo "${account}${storage}${project}"
|
||||||
}
|
}
|
||||||
|
|
||||||
connect_webserver(){
|
connect_shell(){
|
||||||
local webserver="@shell.osdn.net:/home/groups/m/ma/"
|
local shell="@shell.osdn.net:/home/groups/m/ma/"
|
||||||
echo "${account}${webserver}${project}"
|
echo "${account}${shell}${project}"
|
||||||
}
|
}
|
||||||
|
|
||||||
make_torrent(){
|
make_torrent(){
|
||||||
find ${src_dir} -type f -name "*.torrent" -delete
|
find ${src_dir} -type f -name "*.torrent" -delete
|
||||||
|
|
||||||
if [[ -n $(find ${src_dir} -type f -name "*.iso") ]]; then
|
if [[ -n $(find ${src_dir} -type f -name "*.iso") ]]; then
|
||||||
for iso in $(ls ${src_dir}/*.iso); do
|
isos=$(ls ${src_dir}/*.iso)
|
||||||
|
for iso in ${isos}; do
|
||||||
local seed=https://${host}/dl/${project}/${iso##*/}
|
local seed=https://${host}/dl/${project}/${iso##*/}
|
||||||
local mktorrent_args=(-c "${torrent_meta}" -p -l ${piece_size} -a ${tracker_url} -w ${seed})
|
local mktorrent_args=(-c "${torrent_meta}" -p -l ${piece_size} -a ${tracker_url} -w ${seed})
|
||||||
${verbose} && mktorrent_args+=(-v)
|
${verbose} && mktorrent_args+=(-v)
|
||||||
|
@ -41,6 +42,9 @@ prepare_transfer(){
|
||||||
[[ -z ${project} ]] && project="$(get_project)"
|
[[ -z ${project} ]] && project="$(get_project)"
|
||||||
server=$(connect)
|
server=$(connect)
|
||||||
|
|
||||||
|
webshell=$(connect_shell)
|
||||||
|
htdocs="htdocs/${profile}"
|
||||||
|
|
||||||
target_dir="${profile}/${dist_release}"
|
target_dir="${profile}/${dist_release}"
|
||||||
src_dir="${run_dir}/${edition}/${target_dir}"
|
src_dir="${run_dir}/${edition}/${target_dir}"
|
||||||
|
|
||||||
|
@ -80,15 +84,19 @@ sync_dir(){
|
||||||
msg "Start upload [%s] to [%s] ..." "$1" "${project}"
|
msg "Start upload [%s] to [%s] ..." "$1" "${project}"
|
||||||
|
|
||||||
while [[ $count -le $max_count ]]; do
|
while [[ $count -le $max_count ]]; do
|
||||||
rsync ${rsync_args[*]} --exclude '.latest*' ${src_dir}/ ${server}/${target_dir}/
|
rsync ${rsync_args[*]} --exclude '.latest*' --exclude 'index.html' --exclude 'links.txt' ${src_dir}/ ${server}/${target_dir}/
|
||||||
if [[ $? != 0 ]]; then
|
if [[ $? != 0 ]]; then
|
||||||
count=$(($count + 1))
|
count=$(($count + 1))
|
||||||
msg "Upload failed. retrying (%s/%s) ..." "$count" "$max_count"
|
msg "Upload failed. retrying (%s/%s) ..." "$count" "$max_count"
|
||||||
sleep 2
|
sleep 2
|
||||||
else
|
else
|
||||||
count=$(($max_count + 1))
|
count=$(($max_count + 1))
|
||||||
[[ -f "${src_dir}/.latest" ]] && sync_latest_html
|
|
||||||
[[ -f "${src_dir}/.latest.php" ]] && sync_latest_php
|
# sync latest files
|
||||||
|
# manjaro.osdn.io
|
||||||
|
# manjaro-community.osdn.io
|
||||||
|
sync_web_shell
|
||||||
|
|
||||||
msg "Done upload [%s]" "$1"
|
msg "Done upload [%s]" "$1"
|
||||||
show_elapsed_time "${FUNCNAME}" "${timer_start}"
|
show_elapsed_time "${FUNCNAME}" "${timer_start}"
|
||||||
fi
|
fi
|
||||||
|
@ -96,20 +104,74 @@ sync_dir(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sync_latest_html(){
|
sync_web_shell(){
|
||||||
msg2 "Uploading url redirector ..."
|
if [[ -f "${src_dir}/.latest" ]]; then
|
||||||
local webserver=$(connect_webserver)
|
LINKS="links.txt"
|
||||||
local htdocs="htdocs/${profile}"
|
LATEST_ISO=$(sed -e 's/\"/\n/g' < "${src_dir}/.latest" | grep -Eo 'http.*iso$' -m1 | awk '{split($0,x,"/"); print x[6]}')
|
||||||
local html="latest"
|
PKGLIST="${LATEST_ISO/.iso/-pkgs.txt}"
|
||||||
scp "${src_dir}/.${html}" "${webserver}/${htdocs}/${html}"
|
|
||||||
rm -f "${src_dir}/.${html}"
|
[[ -f "${src_dir}/.latest" ]] && sync_latest_html
|
||||||
|
[[ -f "${src_dir}/.latest.php" ]] && sync_latest_php
|
||||||
|
|
||||||
|
[[ -f "${src_dir}/${LATEST_ISO}.torrent" ]] && sync_latest_torrent
|
||||||
|
[[ -f "${src_dir}/${LATEST_ISO}.sig" ]] && sync_latest_signature
|
||||||
|
[[ -f "${src_dir}/${LATEST_ISO}.sha1" ]] && sync_latest_checksum_sha1
|
||||||
|
[[ -f "${src_dir}/${LATEST_ISO}.sha256" ]] && sync_latest_checksum_sha256
|
||||||
|
[[ -f "${src_dir}/${PKGLIST}" ]] && sync_latest_pkg_list
|
||||||
|
|
||||||
|
#sync_latest_index
|
||||||
|
|
||||||
|
rm -f "${src_dir}/latest"
|
||||||
|
rm -f "${src_dir}/latest.php"
|
||||||
|
rm -f "${src_dir}/*.iso.torrent"
|
||||||
|
rm -f "${src_dir}/*.iso.sig"
|
||||||
|
rm -f "${src_dir}/*.iso.sha1"
|
||||||
|
rm -f "${src_dir}/*.iso.sha256"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_latest_pkg_list(){
|
||||||
|
msg2 "Uploading package list ..."
|
||||||
|
local pkglist="latest-pkgs.txt"
|
||||||
|
scp "${src_dir}/${PKGLIST}" "${webshell}/${htdocs}/${pkglist}"
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_latest_checksum_sha256(){
|
||||||
|
msg2 "Uploading sha256 checksum file ..."
|
||||||
|
local filename="${LATEST_ISO}.sha256"
|
||||||
|
local checksum_file="latest.sha256"
|
||||||
|
scp "${src_dir}/${filename}" "${webshell}/${htdocs}/${checksum_file}"
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_latest_checksum_sha1(){
|
||||||
|
msg2 "Uploading sha1 checksum file ..."
|
||||||
|
local filename="${LATEST_ISO}.sha1"
|
||||||
|
local checksum_file="latest.sha1"
|
||||||
|
scp "${src_dir}/${filename}" "${webshell}/${htdocs}/${checksum_file}"
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_latest_signature(){
|
||||||
|
msg2 "Uploading signature file ..."
|
||||||
|
local filename="${LATEST_ISO}.sig"
|
||||||
|
local signature="latest.sig"
|
||||||
|
scp "${src_dir}/${filename}" "${webshell}/${htdocs}/${signature}"
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_latest_torrent(){
|
||||||
|
msg2 "Uploading torrent file ..."
|
||||||
|
local filename="${LATEST_ISO}.torrent"
|
||||||
|
local torrent="latest.torrent"
|
||||||
|
scp "${src_dir}/${filename}" "${webshell}/${htdocs}/${torrent}"
|
||||||
}
|
}
|
||||||
|
|
||||||
sync_latest_php(){
|
sync_latest_php(){
|
||||||
msg2 "Uploading php redirector ..."
|
msg2 "Uploading php redirector ..."
|
||||||
local webserver=$(connect_webserver)
|
|
||||||
local htdocs="htdocs/${profile}"
|
|
||||||
local php="latest.php"
|
local php="latest.php"
|
||||||
scp "${src_dir}/.${php}" "${webserver}/${htdocs}/${php}"
|
scp "${src_dir}/.${php}" "${webshell}/${htdocs}/${php}"
|
||||||
rm -f "${src_dir}/.${php}"
|
}
|
||||||
|
|
||||||
|
sync_latest_html(){
|
||||||
|
msg2 "Uploading url redirector ..."
|
||||||
|
local html="latest"
|
||||||
|
scp "${src_dir}/.latest" "${webshell}/${htdocs}/${html}"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue