Skip to content
Snippets Groups Projects
Unverified Commit 38f981a5 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

create-notification: Backwards compatibility

Accept single language as well as both. But warn in such case.
parent 8d621775
No related branches found
No related tags found
No related merge requests found
......@@ -3,9 +3,9 @@
base_dir=/tmp/user_notify
usage() {
echo "This program serves for creating messages which will be send to the user."
echo "Usage:"
echo -e "\t $0 -s [restart,error,update,news] 'Czech text of the message' 'English text of the message'"
echo "This program serves for creating messages which will be send to the user." >&2
echo "Usage:" >&2
echo -e "\t $0 -s [restart,error,update,news] 'Czech text of the message' 'English text of the message'" >&2
}
trigger=false
......@@ -20,9 +20,14 @@ if [ "$1" = -d ] ; then
shift 2
fi
if [ $# -ne 4 ]; then
if [ $# -eq 3 ]; then
echo "Backwards compatibility mode: using only single language. Please provide both languages." >&2
compat=true
elif [ $# -ne 4 ]; then
usage
exit 1
else
compat=false
fi
if [ "$1" = "-s" ]; then
......@@ -45,8 +50,12 @@ msg_id="$(/bin/busybox date +%s)-$$"
mkdir -p "$base_dir"
mkdir "$base_dir/tmp.$msg_id"
echo "$severity" > "$base_dir/tmp.$msg_id/severity"
echo "$message_cs" > "$base_dir/tmp.$msg_id/message_cs"
echo "$message_en" > "$base_dir/tmp.$msg_id/message_en"
if $compat ; then
echo "$message_cs" > "$base_dir/tmp.$msg_id/message"
else
echo "$message_cs" > "$base_dir/tmp.$msg_id/message_cs"
echo "$message_en" > "$base_dir/tmp.$msg_id/message_en"
fi
mv "$base_dir/tmp.$msg_id" "$base_dir/$msg_id"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment