nix-tools/bin/deployiso.in

126 lines
3.1 KiB
Text
Raw Normal View History

#!/bin/bash
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
version=@version@
LIBDIR='@libdir@'
SYSCONFDIR='@sysconfdir@'
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
import ${LIBDIR}/util.sh
2015-11-12 19:03:51 +01:00
import ${LIBDIR}/util-publish.sh
2015-11-23 20:02:56 +01:00
show_profile(){
eval_edition "$1"
cd ${run_dir}/${edition_type}/$1
2015-11-30 21:55:54 +01:00
msg3 "Iso: [$1]"
prepare_transfer "$1"
2015-11-30 23:12:27 +01:00
msg2 "src_dir: ${src_dir}"
msg2 "remote_dir: ${remote_dir}"
cd ${run_dir}
2015-11-23 20:02:56 +01:00
}
display_settings(){
show_version
show_config
2015-11-12 00:31:51 +01:00
2015-11-17 17:05:06 +01:00
msg "PROFILE:"
msg2 "sets_dir_iso: ${sets_dir_iso}"
msg2 "buildsets: $(load_sets ${sets_dir_iso})"
msg2 "buildset_iso: ${buildset_iso}"
msg2 "is_buildset: ${is_buildset}"
2015-11-24 16:58:40 +01:00
msg "OPTIONS:"
2015-11-27 12:22:38 +01:00
msg2 "arch: ${arch}"
2015-11-24 16:58:40 +01:00
msg2 "limit: ${limit} kB/s"
2015-11-24 10:31:27 +01:00
msg "ARGS:"
msg2 "update: ${update}"
msg2 "remote_create: ${remote_create}"
2015-11-26 12:24:55 +01:00
msg2 "verbose: ${verbose}"
msg2 "rsync_args: ${rsync_args[*]}"
2015-11-12 00:31:51 +01:00
msg "HOST:"
2015-11-12 12:25:35 +01:00
msg2 "dist_release: ${dist_release}"
2015-11-12 00:31:51 +01:00
msg "REMOTE:"
msg2 "remote_url: ${remote_url}"
msg2 "remote_project: ${remote_project}"
msg2 "remote_target: ${remote_target}"
msg2 "remote_user: ${remote_user}"
2015-11-17 17:05:06 +01:00
msg "UPLOAD QUEUE:"
2015-11-28 17:37:13 +01:00
run show_profile "${buildset_iso}"
2015-11-12 17:49:38 +01:00
}
load_user_info
load_config "${USER_CONFIG}/manjaro-tools.conf"
load_config "${SYSCONFDIR}/manjaro-tools.conf"
2015-12-03 12:02:23 +01:00
run_dir=${cache_dir_iso}
pretend=false
2015-11-23 20:48:13 +01:00
remote_create=false
update=false
2015-11-26 12:24:55 +01:00
verbose=false
2015-11-26 12:24:55 +01:00
rsync_args=(-aP --progress -e ssh)
2015-11-12 12:25:35 +01:00
usage() {
echo "Usage: ${0##*/} [options]"
2015-11-17 17:05:06 +01:00
echo " -p Source folder to upload [default:${buildset_iso}]"
2015-11-27 12:22:38 +01:00
echo " -a Arch to upload [default:${arch}]"
2015-11-25 19:52:56 +01:00
echo " -l Limit bandwidth in kB/s [default:${limit}]"
2015-11-23 20:48:13 +01:00
echo ' -c Create new remote edition_type with subtree'
2015-11-24 16:58:40 +01:00
echo ' -u Update remote iso'
2015-11-12 17:49:38 +01:00
echo ' -q Query settings and pretend upload'
2015-11-26 12:24:55 +01:00
echo ' -v Verbose output'
echo ' -h This help'
echo ''
echo ''
exit $1
}
2015-11-27 12:22:38 +01:00
opts='p:a:l:cuvqh'
while getopts "${opts}" arg; do
case "${arg}" in
2015-11-17 17:05:06 +01:00
p) buildset_iso="$OPTARG" ;;
2015-11-27 12:22:38 +01:00
a) arch="$OPTARG" ;;
2015-11-25 19:52:56 +01:00
l) limit="$OPTARG" ;;
2015-11-23 20:48:13 +01:00
c) remote_create=true ;;
u) update=true; rsync_args+=(-u) ;;
2015-11-26 12:24:55 +01:00
v) verbose=true; rsync_args+=(-v --stats) ;;
2015-11-25 19:55:59 +01:00
q) pretend=true; rsync_args+=(-n) ;;
h|?) usage 0 ;;
*) echo "invalid argument '${arg}'"; usage 1 ;;
esac
done
shift $(($OPTIND - 1))
timer_start=$(get_timer)
2015-12-01 12:24:23 +01:00
eval_buildset "${sets_dir_iso}" "${buildset_iso}"
2015-11-17 17:05:06 +01:00
2015-11-25 19:52:56 +01:00
rsync_args+=(--bwlimit=${limit})
2015-11-13 12:34:24 +01:00
sf_url=${remote_user},${remote_project}@frs.${remote_url}:${remote_target}/${remote_project}
2015-11-20 22:23:02 +01:00
shell_url=${remote_user},${remote_project}@shell.${remote_url}
cd ${run_dir}
${pretend} && display_settings && exit 1
2015-11-28 17:37:13 +01:00
run sync_dir "${buildset_iso}"