Korrekturen damit der Build wieder laeuft
[people/pmueller/ipfire-2.x.git] / src / pakfire / lib / functions.sh
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 . /etc/sysconfig/rc
23 . $rc_functions
24
25 extract_files() {
26 echo "Extracting files..."
27 tar xvf /opt/pakfire/tmp/files --preserve --numeric-owner -C /
28 echo "...Finished."
29 }
30
31 remove_files() {
32 echo "Removing files..."
33 for i in $(cat /opt/pakfire/tmp/ROOTFILES); do
34 rm -rfv ${i}
35 done
36 echo "...Finished."
37 }
38
39 make_backup(){
40 [ -e "/var/ipfire/backup/addons/include/${1}" ] && \
41 ( echo "Creating Backup..."
42 /usr/local/bin/backupctrl addonbackup ${1}
43 echo "...Finished." )
44 }
45
46 restore_backup(){
47 [ -e "/var/ipfire/backup/addons/backup/${1}" ] && \
48 ( echo "Restoring Backup..." && \
49 /usr/local/bin/backupctrl restoreaddon ${1} && \
50 echo "...Finished." )
51 }
52
53 restart_service() {
54
55 /etc/init.d/$1 restart
56
57 }
58
59 start_service() {
60 DELAY=0
61 while true
62 case "${1}" in
63 --delay|-d)
64 DELAY=${2}
65 shift 2
66 ;;
67 --background|-b)
68 BACKGROUND="&"
69 shift
70 ;;
71 -*)
72 log_failure_msg "Unknown Option: ${1}"
73 return 2 #invalid or excess argument(s)
74 ;;
75 *)
76 break
77 ;;
78 esac
79
80 [ -e "/etc/init.d/${1}" ] && \
81 (sleep ${DELAY} && /etc/init.d/${1} start ${BACKGROUND})
82 }
83
84 stop_service() {
85
86 [ -e "/etc/init.d/${1}" ] && /etc/init.d/${1} stop
87
88 }