Compare commits

..

2 commits

Author SHA1 Message Date
Micke Nordin 6265472396 Make it possible to delete announcement with just subject 2023-11-22 11:52:58 +01:00
Micke Nordin b40beeb420 Install xmlstarlet 2023-11-22 11:04:20 +01:00
2 changed files with 47 additions and 0 deletions

View file

@ -80,6 +80,10 @@ class sunetdrive::script (
ensure => installed, ensure => installed,
provider => apt, provider => apt,
} }
package { 'xmlstarlet':
ensure => installed,
provider => apt,
}
$drive_version = '0.3.1' $drive_version = '0.3.1'
if $facts['os']['distro']['id'] == 'Debian' { if $facts['os']['distro']['id'] == 'Debian' {
$pip_cmd = 'pip3 install --break-system-packages' $pip_cmd = 'pip3 install --break-system-packages'
@ -323,6 +327,13 @@ class sunetdrive::script (
group => 'root', group => 'root',
mode => '0700', mode => '0700',
} }
file { '/root/tasks/delete_announcement_with_subject.sh':
ensure => file,
content => template('sunetdrive/script/delete_announcement_with_subject.erb.sh'),
owner => 'root',
group => 'root',
mode => '0700',
}
file { '/root/tasks/backupmultinodedb.sh': file { '/root/tasks/backupmultinodedb.sh':
ensure => file, ensure => file,
content => template('sunetdrive/script/backupmultinodedb.erb.sh'), content => template('sunetdrive/script/backupmultinodedb.erb.sh'),

View file

@ -0,0 +1,36 @@
#!/bin/bash
VALID_ARGS=$(getopt -o s --long subject -- "$@")
# shellcheck disable=SC2181
if [[ ${?} -ne 0 ]]; then
exit 1;
fi
usage () {
echo "${0}: -s|--subject <subject>"
exit 1
}
eval set -- "${VALID_ARGS}"
# shellcheck disable=SC2078
while [ : ]; do
case "$1" in
-s | --subject)
subject="${2}"
shift 2
;;
*)
break
;;
esac
done
if [[ -z ${subject} ]]; then
usage
fi
fi
id=$(/root/tasks/announce.sh --get | xmlstarlet sel -t -i '//subject="'${subject}'"' -m "/ocs/data/element/id" -v .)
if [[ -n ${id} ]]; then
/root/tasks/announce.sh --delete --id "${id}"
fi