]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/bash | |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007-2021 IPFire Team <info@ipfire.org> # | |
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 | TAR_OPTIONS=( | |
26 | --acls | |
27 | --xattrs | |
28 | --xattrs-include='*' | |
29 | --no-overwrite-dir | |
30 | --no-delay-directory-restore | |
31 | --preserve-permissions | |
32 | --numeric-owner | |
33 | ) | |
34 | ||
35 | extract_files() { | |
36 | echo "Extracting files..." | |
37 | tar -xavf /opt/pakfire/tmp/files* "${TAR_OPTIONS[@]}" -C / | |
38 | sync | |
39 | echo "...Finished." | |
40 | } | |
41 | ||
42 | extract_backup_includes() { | |
43 | echo "Extracting backup includes..." | |
44 | tar xavf /opt/pakfire/tmp/files* "${TAR_OPTIONS[@]}" -C / \ | |
45 | var/ipfire/backup/addons/includes | |
46 | sync | |
47 | echo "...Finished." | |
48 | } | |
49 | ||
50 | remove_files() { | |
51 | echo "Removing files..." | |
52 | for i in $(cat /opt/pakfire/db/rootfiles/${NAME}); do | |
53 | rm -rfv /${i} | |
54 | done | |
55 | echo "...Finished." | |
56 | } | |
57 | ||
58 | make_backup() { | |
59 | if [ -e "/var/ipfire/backup/addons/includes/${1}" ]; then | |
60 | echo "Creating Backup..." | |
61 | /usr/local/bin/backupctrl addonbackup ${1} | |
62 | echo "...Finished." | |
63 | fi | |
64 | } | |
65 | ||
66 | restore_backup() { | |
67 | if [ -e "/var/ipfire/backup/addons/backup/${1}.ipf" ]; then | |
68 | echo "Restoring Backup..." | |
69 | /usr/local/bin/backupctrl restoreaddon ${1}.ipf | |
70 | echo "...Finished." | |
71 | fi | |
72 | } | |
73 | ||
74 | restart_service() { | |
75 | /etc/init.d/${1} restart | |
76 | } | |
77 | ||
78 | start_service() { | |
79 | DELAY=0 | |
80 | while true | |
81 | do | |
82 | case "${1}" in | |
83 | --delay|-d) | |
84 | DELAY=${2} | |
85 | shift 2 | |
86 | ;; | |
87 | --background|-b) | |
88 | BACKGROUND="&" | |
89 | shift | |
90 | ;; | |
91 | -*) | |
92 | log_failure_msg "Unknown Option: ${1}" | |
93 | return 2 #invalid or excess argument(s) | |
94 | ;; | |
95 | *) | |
96 | break | |
97 | ;; | |
98 | esac | |
99 | done | |
100 | ||
101 | if [ -f "/etc/init.d/${1}" ]; then | |
102 | if [ -n "${BACKGROUND}" ]; then | |
103 | (sleep ${DELAY} && /etc/init.d/${1} start) & | |
104 | else | |
105 | sleep ${DELAY} && /etc/init.d/${1} start | |
106 | fi | |
107 | fi | |
108 | } | |
109 | ||
110 | stop_service() { | |
111 | if [ -f "/etc/init.d/${1}" ]; then | |
112 | /etc/init.d/${1} stop | |
113 | fi | |
114 | } | |
115 | ||
116 | rebuild_langcache() { | |
117 | echo "Rebuilding language cache..." | |
118 | perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" | |
119 | echo "...Finished." | |
120 | } | |
121 |