/
likewise-open.postrm
95 lines (86 loc) · 1.64 KB
/
likewise-open.postrm
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
#!/bin/sh
LOG=/var/log/likewise-open-install.log
TLOG=/tmp/likewise-open-install.txt
# Display to screen and log file with a blank line.
log()
{
echo $@
echo
echo $@ >> $LOG
echo >> $LOG
}
_log()
{
echo $@
echo $@ >> $LOG
}
# Display to file.
logfile()
{
echo $@ >> $LOG
echo >> $LOG
}
# Execute command.
# If successful, note in log file.
# If not successful, note on screen and log file.
exec_log()
{
$@ > $TLOG 2>&1
err=$?
if [ $err -eq 0 ]; then
echo "Success: $@" >> $LOG
cat $TLOG >> $LOG
echo >> $LOG
else
_log "Warning: $@ returned $err"
_log `cat $TLOG`
_log
fi
rm -f $TLOG > /dev/null 2>&1
return $err
}
# Execute command.
# Log only to file.
exec_logfile()
{
$@ > $TLOG 2>&1
err=$?
if [ $err -eq 0 ]; then
echo "Success: $@" >> $LOG
else
echo "Warning: $@ returned $err" >> $LOG
fi
cat $TLOG >> $LOG
echo >> $LOG
rm -f $TLOG > /dev/null 2>&1
return $err
}
# Execute command.
# If successful, note in log file.
# If not successful, note on screen and log file and then exit.
exec_log_exit()
{
$@ > $TLOG 2>&1
err=$?
if [ $err -eq 0 ]; then
echo "Success: $@" >> $LOG
cat $TLOG >> $LOG
echo >> $LOG
else
_log "Error: $@ returned $err"
_log `cat $TLOG`
_log
rm -f $TLOG > /dev/null 2>&1
exit 1
fi
rm -f $TLOG > /dev/null 2>&1
return $err
}
case "$1" in
purge)
logfile "### likewise-open.postrm purge"
exec_log_exit "rm -rf /var/lib/likewise-open"
exit 0
;;
esac
#DEBHELPER#