File: udconfig

package info (click to toggle)
ud 0.7.1-13
  • links: PTS
  • area: main
  • in suites: woody
  • size: 276 kB
  • ctags: 38
  • sloc: ansic: 704; sh: 522; makefile: 69
file content (73 lines) | stat: -rw-r--r-- 1,559 bytes parent folder | download | duplicates (2)
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
#!/bin/bash
#
# Configure uptime daemon.
#
# Fredrik Hallenberg <hallon@debian.org>
#

set -ef

TEMPFILE=`tempfile -m 700`

fixargs() {
#sed /etc/init.d/ud -e s#ARGS=\".*\"#ARGS=\""$1"\"# > $TEMPFILE
#mv /etc/init.d/ud /etc/init.d/ud.old
#mv $TEMPFILE /etc/init.d/ud
#chmod 0755 /etc/init.d/ud
#rm /etc/init.d/ud.old
echo $1 > /etc/ud/config
}

if [ `whoami` != "root" ]; then
  echo "This script must be run by root."
  exit 1
fi

if [ ! -f /etc/init.d/ud ]; then
  echo "Can\'t find /etc/init.d/ud! Please reinstall the ud package or"
  echo "rename /etc/init.d/ud.old to /etc/init.d/ud"
  exit 1
fi

if [ ! -f /etc/ud/template.html ]; then
  echo "Cant\'t find /etc/ud/template.html! Please reinstall the ud package"
  exit 1
fi

cat <<EOF
The Uptime Daemon has the ability to generate a HTML page with your current
uptime status. This page is generated by using a template.

EOF

read -p "Do you want ud to generate a HTML page? [yN]: " KEY
case "$KEY" in
  y|Y)
    read -p "Path of the HTML file: " HTMLFILE
    if [ "$HTMLFILE" = "" ]; then
      echo "No changes made."
      exit 0
    fi
    cat <<EOF

If you want to use the default template file /etc/ud/template.html just press return now.
If not enter the path of the desired template.

EOF
    read -p "Path to template [/etc/ud/template.html]: " TEMPLATE
    if [ "$TEMPLATE" = "" ]; then
      TEMPLATE="/etc/ud/template.html"
    fi
    fixargs "-of ${HTMLFILE} -if ${TEMPLATE}"
    ;;
  *)
    fixargs "-s"
    ;;
esac

/etc/init.d/ud restart

echo ""
echo "Configuration updated."

exit 0