summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsteban Carnevale <alfplayer@mailoo.org>2014-11-07 13:46:29 -0300
committerEsteban Carnevale <alfplayer@mailoo.org>2014-11-07 13:46:29 -0300
commitfb0137f2ae5a7e13ceede6f373b6ad68a0e6ea7c (patch)
tree93d1bf34692a65021b228c7ed21885a2b368bc1a
parentf1a771204c474e5d5498d8e4a1951eb56f948f4f (diff)
parabola-mirror-repos: Variable name to lowercase
-rwxr-xr-xparabola-mirror-repos90
1 files changed, 45 insertions, 45 deletions
diff --git a/parabola-mirror-repos b/parabola-mirror-repos
index d2245c0..301da9e 100755
--- a/parabola-mirror-repos
+++ b/parabola-mirror-repos
@@ -21,7 +21,7 @@ log_tmp="$(mktemp -p /var/tmp)"
: ${SERVER:=rsync://alfplayer.com/repos/parabola} # remote rsync directory
#: ${SERVER:=rsync://parabolagnulinux.mirrors.linux.ro/parabolagnulinux}
: ${base_dir:=/srv/http}
-: ${LOCAL:=${base_dir}/${project}} # symlink to the last snapshot
+: ${local_dir:=${base_dir}/${project}} # symlink to the last snapshot
: ${REPOS:=core extra community multilib libre kernels libre-multilib libre-multilib-testing libre-testing nonprism nonprism-testing java cross pcr}
# mips64el is also excluded in some rsync invocations in this script
: ${MAXDELETE:=10000} # maximum amount of files to delete in the local directory
@@ -38,7 +38,7 @@ log_tmp="$(mktemp -p /var/tmp)"
: ${date_exclude:=2014.06.19} # disable running this script this date (see next line)
: ${forcerun:=0} # set to 1 to force running on excluded date
: ${terminal:=1} # outputs to stdout using rsync --progress (and logs to a file)
-: ${alternative_mirror:=0} # use alternative mirror; forces no_snapshot_delete and disables snapshot_symlink_update; synchronized files end up in ${LOCAL}.tmp
+: ${alternative_mirror:=0} # use alternative mirror; forces no_snapshot_delete and disables snapshot_symlink_update; synchronized files end up in ${local_dir}.tmp
: ${no_snapshot_delete:=0} # disable deletion of oldest snapshots; alternative_mirror enables it forcefully
: ${leave_tmp:=0} # leave updated tree in {project}.tmp instead of creating a dated snapshot directory
: ${snapshot_symlink_update:=1} # update symlink to last snapshot
@@ -59,10 +59,10 @@ if [[ ${alternative_mirror} == 1 ]] ; then
leave_tmp=1
#SERVER="rsync://repo.parabola.nu:875/repos"
SERVER="rsync://parabolagnulinux.mirrors.linux.ro/parabolagnulinux"
- LOCAL="${base_dir}/${project}.secondary_mirror"
+ local_dir="${base_dir}/${project}.secondary_mirror"
#link_dest=("${base_dir}/archlinux" "${base_dir}/parabola.tmp")
link_dest+=("${base_dir}/${project}.tmp")
- for dir in "$LOCAL" "$LOCAL".tmp ${LOCAL}.tmp/pool ; do
+ for dir in "$local_dir" "$local_dir".tmp ${local_dir}.tmp/pool ; do
if [[ ! -d "$dir" ]] ; then
mkdir -pv "$dir"
chmod -v 2770 "$dir"
@@ -109,8 +109,8 @@ _no_more_locking() {
echo "=> ERROR: Failed to write to log file: ${log_file}" >&2
fi
- if [[ -e ${LOCAL}.tmp ]] ; then
- echo "=> WARNING: Temporary directory ${LOCAL}.tmp remains in file system"
+ if [[ -e ${local_dir}.tmp ]] ; then
+ echo "=> WARNING: Temporary directory ${local_dir}.tmp remains in file system"
fi
if [[ ${mail_to} ]] ; then
@@ -146,7 +146,7 @@ if ! _lock xn ; then
fi
DATE="$(date +%Y.%m.%d)"
-current="${LOCAL}-${DATE}"
+current="${local_dir}-${DATE}"
current_component="${current##*/}"
for (( link_dest_count=1 ; link_dest_count <= ${link_dest_snapshot_count} ; link_dest_count++ )) ; do
date_count="$(date -d @$(( $(date +"%s") - ${link_dest_count} * 86400)) +"%Y.%m.%d")"
@@ -208,25 +208,25 @@ if [[ -e ${current} ]] ; then
current_exists=1
fi
-# Test if ${LOCAL}.tmp exists
-if [[ -e ${LOCAL}.tmp ]] ; then
+# Test if ${local_dir}.tmp exists
+if [[ -e ${local_dir}.tmp ]] ; then
tmp_exists=1
fi
-# Test if ${LOCAL} is an existing symlink pointing to an existing directory
-if [[ -h ${LOCAL} ]] ; then
- last_path="$(readlink -f "${LOCAL}")"
+# Test if ${local_dir} is an existing symlink pointing to an existing directory
+if [[ -h ${local_dir} ]] ; then
+ last_path="$(readlink -f "${local_dir}")"
if [[ -d ${last_path} ]] ; then
last="${last_path##*/}"
local_useful=1
else
- error "=> ERROR: ${LOCAL} is a symlink which does not point to an existing directory."
+ error "=> ERROR: ${local_dir} is a symlink which does not point to an existing directory."
fi
else
- if [[ -e ${LOCAL} ]] || stat -t ${LOCAL}-* >/dev/null 2>&1 ; then
- error "=> ERROR: ${LOCAL} exists but is not a symlink, or a file (or directory) ${LOCAL}-* was found. Fix this before running ${script_filename} again."
+ if [[ -e ${local_dir} ]] || stat -t ${local_dir}-* >/dev/null 2>&1 ; then
+ error "=> ERROR: ${local_dir} exists but is not a symlink, or a file (or directory) ${local_dir}-* was found. Fix this before running ${script_filename} again."
else
- echo "=> WARNING: ${LOCAL} does not exist or is not a symlink, and no snapshot directories were found, so it is assumed this is the first time ${script_filename} is run using \"${base_dir}\" as the base directory."
+ echo "=> WARNING: ${local_dir} does not exist or is not a symlink, and no snapshot directories were found, so it is assumed this is the first time ${script_filename} is run using \"${base_dir}\" as the base directory."
first_run=1
fi
fi
@@ -238,36 +238,36 @@ if [[ ${current_exists} == 1 ]] ; then
no_snapshot_delete=1
if [[ ${local_useful} == 1 ]] ; then
if [[ ${tmp_exists} == 0 ]] ; then
- echo "=> WARNING: ${LOCAL}.tmp does not exist."
- cp -al "${current}" "${LOCAL}".tmp
+ echo "=> WARNING: ${local_dir}.tmp does not exist."
+ cp -al "${current}" "${local_dir}".tmp
fi
date_exact="$(date +%Y.%m.%d-%T)"
- echo "=> WARNING: Snapshot ${LOCAL}-${date_exact} will be created because ${current} already exists"
+ echo "=> WARNING: Snapshot ${local_dir}-${date_exact} will be created because ${current} already exists"
else
- echo "=> WARNING: ${LOCAL} does not exist. It will be created."
+ echo "=> WARNING: ${local_dir} does not exist. It will be created."
if [[ ${tmp_exists} == 0 ]] ; then
- echo "=> WARNING: As ${LOCAL}.tmp does not exist, data transfer will start from ${current}"
- cp -al "${current}" "${LOCAL}".tmp
+ echo "=> WARNING: As ${local_dir}.tmp does not exist, data transfer will start from ${current}"
+ cp -al "${current}" "${local_dir}".tmp
else
- echo "=> WARNING: Data transfer will start from ${LOCAL}.tmp"
+ echo "=> WARNING: Data transfer will start from ${local_dir}.tmp"
fi
fi
elif [[ ${local_useful} == 0 ]] ; then
if [[ ${tmp_exists} == 1 ]] ; then
- echo "=> ${LOCAL} is not useful but ${LOCAL}.tmp exists. Resuming from ${LOCAL}.tmp"
- echo "=> WARNING: Symlink ${LOCAL} does not exist. It will be created."
+ echo "=> ${local_dir} is not useful but ${local_dir}.tmp exists. Resuming from ${local_dir}.tmp"
+ echo "=> WARNING: Symlink ${local_dir} does not exist. It will be created."
else
if [[ ${first_run} == 0 ]] ; then
- error "=> ERROR: ${LOCAL}.tmp does not exist and ${LOCAL} is not useful. Exiting."
+ error "=> ERROR: ${local_dir}.tmp does not exist and ${local_dir} is not useful. Exiting."
else
- mkdir "${LOCAL}".tmp
+ mkdir "${local_dir}".tmp
fi
fi
else
if [[ ${tmp_exists} == 1 ]] ; then
- echo "=> ${LOCAL}.tmp already exists. Symlink \"${project}\" currently points to ${last_path}."
+ echo "=> ${local_dir}.tmp already exists. Symlink \"${project}\" currently points to ${last_path}."
else
- cp -al "${last_path}" "${LOCAL}".tmp
+ cp -al "${last_path}" "${local_dir}".tmp
fi
fi
@@ -275,7 +275,7 @@ echo
echo "=> Creating snapshot for date ${DATE}"
# Change to the temporary directory
-cd "${LOCAL}".tmp
+cd "${local_dir}".tmp
if [[ ${db_and_symlinks_update} == 1 ]] ; then
@@ -336,7 +336,7 @@ if [[ ${db_and_symlinks_update} == 1 ]] ; then
echo "=> Starting to synchronize repository directories (symlinks and db.* files)"
-rsync $OPTIONS --stats --exclude 'mips64el' --delete-after --safe-links "${link_dest_option[@]}" --link-dest="$LOCAL" "${repos_array[@]/#/${SERVER}/}" "$LOCAL".tmp || error " => ERROR: rsync terminated with an error code: $?"
+rsync $OPTIONS --stats --exclude 'mips64el' --delete-after --safe-links "${link_dest_option[@]}" --link-dest="$local_dir" "${repos_array[@]/#/${SERVER}/}" "$local_dir".tmp || error " => ERROR: rsync terminated with an error code: $?"
fi
@@ -354,13 +354,13 @@ _wait_log_tmp
if [[ ${pools_update} == 1 ]] ; then
- rsync $OPTIONS --stats --exclude '*-mips64el.pkg.tar.*' --safe-links --files-from="$REMOTE_POOL_FILES" "${link_dest_option[@]}" --link-dest="$LOCAL" $SERVER "${LOCAL}".tmp
+ rsync $OPTIONS --stats --exclude '*-mips64el.pkg.tar.*' --safe-links --files-from="$REMOTE_POOL_FILES" "${link_dest_option[@]}" --link-dest="$local_dir" $SERVER "${local_dir}".tmp
fi # end "if [[ ${pools_update} == 1 ]]"
if [[ ${path_list} ]] ; then
echo "=> Synchronizing extra paths"
- rsync $OPTIONS --stats --safe-links "${link_dest_option[@]/%//$path}" --link-dest="$LOCAL"/"$path" ${path_list_array[@]/#/${SERVER}/} "${LOCAL}".tmp/ || error " => ERROR: rsync terminated with an error code: $?"
+ rsync $OPTIONS --stats --safe-links "${link_dest_option[@]/%//$path}" --link-dest="$local_dir"/"$path" ${path_list_array[@]/#/${SERVER}/} "${local_dir}".tmp/ || error " => ERROR: rsync terminated with an error code: $?"
fi
{
@@ -368,7 +368,7 @@ fi
if [[ ${no_snapshot_delete} != 1 ]] ; then
echo "=> DRY-RUN: Delete versions older than the version number: ${oldest_version}."
-delete_list=$(find ${base_dir} -regextype sed -maxdepth 1 -regex "${LOCAL}-[0-9]\{4\}\.[0-9]\{2\}.[0-9]\{2\}" | head -n -"${oldest_version}") && \
+delete_list=$(find ${base_dir} -regextype sed -maxdepth 1 -regex "${local_dir}-[0-9]\{4\}\.[0-9]\{2\}.[0-9]\{2\}" | head -n -"${oldest_version}") && \
if [[ ${delete_list} ]] ; then
echo "DRY_RUN: rm -rf ${delete_list}"
else
@@ -381,27 +381,27 @@ if [[ ${leave_tmp} == 0 ]] ; then
echo "=> Starting to serve the new repository version"
if [[ ${date_exact} ]] ; then
- echo " => Renaming ${LOCAL}.tmp to ${LOCAL}"-"${date_exact}"
- mv "${LOCAL}".tmp "${LOCAL}"-"${date_exact}"
+ echo " => Renaming ${local_dir}.tmp to ${local_dir}"-"${date_exact}"
+ mv "${local_dir}".tmp "${local_dir}"-"${date_exact}"
else
- echo " => Renaming ${LOCAL}.tmp to ${current}"
- mv "${LOCAL}".tmp "${current}"
+ echo " => Renaming ${local_dir}.tmp to ${current}"
+ mv "${local_dir}".tmp "${current}"
fi
if [[ ${snapshot_symlink_update} == 1 ]] ; then
cd ${base_dir}
if [[ ${local_useful} == 1 ]] ; then
- echo " => Deleting symlink $LOCAL"
- rm -rf "${LOCAL}"
+ echo " => Deleting symlink $local_dir"
+ rm -rf "${local_dir}"
fi
# Create symlink
if [[ ${date_exact} ]] ; then
- #echo " => Creating symlink ${LOCAL}-${date_exact} to ${current_component}"
- #ln -s ${current_component}-"${date_exact}" ${LOCAL}-"${date_exact}"
- echo " => Creating symlink ${LOCAL} to ${project}-${date_exact}"
- ln -s ${project}-"${date_exact}" ${LOCAL}
+ #echo " => Creating symlink ${local_dir}-${date_exact} to ${current_component}"
+ #ln -s ${current_component}-"${date_exact}" ${local_dir}-"${date_exact}"
+ echo " => Creating symlink ${local_dir} to ${project}-${date_exact}"
+ ln -s ${project}-"${date_exact}" ${local_dir}
else
echo " => Creating symlink \"${project}\" to ${current_component}"
ln -s ${current_component} ${project}
@@ -409,7 +409,7 @@ if [[ ${leave_tmp} == 0 ]] ; then
fi
fi
-rm -f "$REMOTE_POOL_FILES" "$local_pool_files" "$POOL_FILES_TO_DELETE" "$LOCAL".old || true
+rm -f "$REMOTE_POOL_FILES" "$local_pool_files" "$POOL_FILES_TO_DELETE" "$local_dir".old || true
echo "=> Disk space report"
df -h "${base_dir}"