Version bump (2.3-7)
[ukeyboard.git] / cpanel / ukeyboard-set
blobccbce8f635ca6d82cc3188b3f7af1bc32cf4a743
1 #!/bin/sh
2 store=
3 if [ "x$1" = "x-s" ]; then
4 store=1
5 shift
6 fi
8 if [ "x$1" = x -o "x$2" = x ]; then
9 echo "ukeyboard-set: Missing parameters."
10 exit 1
12 dest="/usr/share/keyboards/$2.vkb"
14 if [ "x$1" = "x-r" -a ! -f "$dest-saved" -a ! -f "$dest-empty" ]; then
15 echo "ukeyboard-set: No previous file stored."
16 exit 4
19 if [ -f "$dest" ]; then
20 if [ ! -h "$dest" ]; then
21 echo "ukeyboard-set: Destination $dest exists and is not a symlink."
22 exit 2
24 if [ "$store" != 1 -o -f "$dest-saved" ]; then
25 rm "$dest"
26 if [ -f "$dest" ]; then
27 echo "ukeyboard-set: Cannot delete current symlink $dest."
28 exit 3
30 else
31 mv "$dest" "$dest-saved"
33 elif [ "$store" = 1 ]; then
34 touch "$dest-empty"
37 if [ "x$1" = "x-r" ]; then
38 if [ -f "$dest-saved" ]; then
39 mv "$dest-saved" "$dest"
40 else
41 rm "$dest" "$dest-empty"
43 elif [ "$store" = 1 ]; then
44 ln -s "$1" "$dest"
45 else
46 ln -s "../ukeyboard/$1.vkb" "$dest"
48 exit 0