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