-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy patheboard-addtheme
More file actions
executable file
·120 lines (103 loc) · 2.36 KB
/
Copy patheboard-addtheme
File metadata and controls
executable file
·120 lines (103 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/sh
#
# eboard-addtheme
# adds a new sound or piece set to the eboard
# config files.
#
# sound info is not yet supported by eboard, but will
# be. this script is intended for use in theme-packs
#
#
DATADIR=`eboard-config --datadir`
usage()
{
cat <<EOF
Usage: eboard-addtheme P graphics-file description
eboard-addtheme S sound-file
EOF
exit $1
}
if test x$DATADIR = x; then
echo "** error **: eboard-config not found in PATH."
exit 2
fi
if test $# = 0; then
usage 1 2>&1;
fi
DESTINATION="$DATADIR"
if test ! -w $DATADIR; then
echo "** warning **: installing to ~/.eboard since $DATADIR isn't writeable"
DESTINATION="$HOME/.eboard"
fi
CONFIGFILE="$DESTINATION/eboard_themes.conf"
TMPFILE="/tmp/temp_themes_conf.$$"
case "$1" in
P)
# do we have the correct number of parameters ?
if test $# -ne 3; then usage 1; fi
# is the file to be installed readable ?
if test ! -r $2; then
echo "$2: not found"
exit 3
fi
# will we overwrite anything ?
if test -r $DESTINATION/$2; then
if diff -q $2 $DESTINATION/$2; then
echo "skipping $2: same file already installed"
exit 4
else
echo "existing $2 will be overwritten"
# remove existing entry from config file
fgrep -v "$2" $CONFIGFILE > $TMPFILE
if test -r $TMPFILE; then
cp -f $TMPFILE $CONFIGFILE
fi
fi
fi
# install it
echo "installing piece set \"$3\" ($2)"
if sh -c "cp -f $2 $DESTINATION/$2"; then
echo "$2,$3" >> $CONFIGFILE
echo "ok"
else
echo "installation of $2 failed"
exit 1
fi
exit 0
;;
S)
# do we have the correct number of parameters ?
if test $# -ne 2; then usage 1; fi
# is the file to be installed readable ?
if test ! -r $2; then
echo "$2: not found"
exit 3
fi
# will we overwrite anything ?
if test -r $DESTINATION/$2; then
if diff -q $2 $DESTINATION/$2; then
echo "skipping $2: same file already installed"
exit 4
else
echo "existing $2 will be overwritten"
# remove existing entry from config file
fgrep -v "$2" $CONFIGFILE > $TMPFILE
if test -r $TMPFILE; then
cp -f $TMPFILE $CONFIGFILE
fi
fi
fi
echo "installing sound file $2"
if sh -c "cp -f $2 $DESTINATION/$2"; then
echo "+$2,sound file" >> $CONFIGFILE
echo "ok"
else
echo "installation of $2 failed"
exit 1
fi
exit 0
;;
*)
usage 1
;;
esac