From 1fae471784a731bf85aa5a5945c540f775127cf4 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Mon, 4 Mar 2013 16:59:58 +0100 Subject: [PATCH] Finish opsi admin tools --- bin/opsi-administration.sh | 70 +++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/bin/opsi-administration.sh b/bin/opsi-administration.sh index 5ff1e11..2770192 100755 --- a/bin/opsi-administration.sh +++ b/bin/opsi-administration.sh @@ -82,7 +82,8 @@ go_show() show_version=$REV_VERSION-$REV_CREATOR_TAG$REV_RELEASE done if [ -n "${show_version}" ];then - echo "./${ARGV0} --root ${OPSI_ROOT} --name ${show_name} --type ${show_type} --from ${show_from} --to ${show_to} --version ${show_version} " >> $show_list + echo "./${ARGV0} --root ${OPSI_ROOT} --name ${show_name} --type ${show_type} --from ${show_from} --to ${show_to} --version ${show_version} (--purge)" >> $show_list + echo "./${ARGV0} --root ${OPSI_ROOT} --name ${show_name} --type ${show_type} --delete ${show_from} --version ${show_version} " >> $show_list else echo "no package named ${show_name}-* in this dir ${show_dir}" >> $show_list fi @@ -117,6 +118,28 @@ go_copy() ln -vf ${copy_from_dir}/${copy_name}{-,_}${copy_version}{.,-}* ${copy_to_dir}/ &>> $copy_list boxes -d shell $copy_list echo "" + + rm -f ${copy_list} +} + +go_delete() +{ + local opsi_dir=$1 + local delete_name=$2 + local delete_type=$3 + local delete_delete=$4 + local delete_version=$5 + local delete_dir="/${opsi_dir}/${delete_type}/${delete_delete}/" + local delete_list=`mktemp /tmp/opsi-administration.delete.list.XXXXXXXXXXX` + echo "" + echo "Web Root : ${delete_dir} Package Name: ${delete_name}" >> $delete_list + echo "" >> $delete_list + rm -f ${delete_dir}/${delete_name}{-,_}${delete_version}{.,-}* &>> $delete_list + boxes -d shell $delete_list + echo "" + + rm -f ${delete_list} + } main() @@ -194,6 +217,21 @@ main() esac fi + # check if the delete is correctly set + if [ -n "${FLAGS_delete}" ] ; then + case "${FLAGS_delete}" in + + integration) + ;; + testing) + ;; + release) + ;; + *) die "to is onyl integration testing or release" + ;; + esac + fi + # set some local vars local show_from="" local show_to="" @@ -215,34 +253,12 @@ main() go_show ${OPSI_ROOT} ${FLAGS_name:-} ${FLAGS_type:-} ${show_from} ${show_to} elif [ -z "${FLAGS_show}" ] && [ -n "${FLAGS_type}" ] && [ -n "${FLAGS_from}" ] && [ -n "${FLAGS_to}" ] && [ -n "${FLAGS_version}" ]; then go_copy ${OPSI_ROOT} ${FLAGS_name:-} ${FLAGS_type:-} ${FLAGS_from:-} ${FLAGS_to:-} ${FLAGS_version:-} ${FLAGS_purge} + elif [ -z "${FLAGS_show}" ] && [ -n "${FLAGS_type}" ] && [ -n "${FLAGS_delete}" ] && [ -n "${FLAGS_version}" ]; then + go_delete ${OPSI_ROOT} ${FLAGS_name:-} ${FLAGS_type:-} ${FLAGS_delete:-} ${FLAGS_version:-} + else + die "read documetation for how to use" fi - # if [ ${FLAGS_dry_run} -eq ${FLAGS_FALSE} -a -f "${output}" ]; then - # if [ ${FLAGS_force} -eq ${FLAGS_TRUE} ]; then - # rm -f "${output}" - # else - # echo "not overwriting '${output}'" >&2 - # exit ${FLAGS_ERROR} - # fi - # fi - # if [ ${FLAGS_dry_run} -eq ${FLAGS_FALSE} ]; then - # touch "${output}" 2>/dev/null || die "unable to write to '${output}'" - # fi - - # run tests - # ( - # cd "${SRC_DIR}"; - # if [ ${FLAGS_dry_run} -eq ${FLAGS_FALSE} ]; then - # ./${FLAGS_suite} |tee "${output}" - # else - # ./${FLAGS_suite} - # fi - # ) - - # if [ ! ${FLAGS_dry_run} ]; then - # echo >&2 - # echo "output written to '${output}'" >&2 - # fi } FLAGS "$@" || exit $?