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