aboutsummaryrefslogtreecommitdiff
path: root/src/jail-update
blob: f6635b505e52549e695e527bb5cb725f932e9daa (plain)
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
#!/bin/bash
#
# jail-update: update config files from a jail to a template
# feedback: rhatto@riseup.net | gpl
#
#  Jail-update is free software; you can redistribute it and/or modify it under the
#  terms of the GNU General Public License as published by the Free Software
#  Foundation; either version 2 of the License, or any later version.
#
#  Jail-update is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
#  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License along with
#  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
#  Place - Suite 330, Boston, MA 02111-1307, USA
#

COMMON="/usr/libexec/simplepkg/common.sh"

if [ -f "$COMMON" ]; then
  source $COMMON
else
  echo "error: file $COMMON found, check your `basename $0` installation"
  exit 1
fi

if [ -f $JAIL_LIST ]; then
  for jailpath in `cat $JAIL_LIST`; do
    jail="`basename $jailpath`"
    echo updating $jailpath...
    if [ -d "$BASE_CONF/$jail.d" ] || [ -a "$BASE_CONF/$jail.template" ]; then
      templatepkg -a $jail $jailpath
      cd $BASE_CONF/$jail.d
      for file in `find`; do
        if [[ -f "$file" && -f "$jailpath/$file" ]]; then
           if ! diff $file $jailpath/$file; then
             echo updating $file
             cp -f $jailpath/$file $file
           fi
        fi
      done
    fi
  done
fi

# main jail
if [ -a "$BASE_CONF/main.template" ]; then
  echo updating main installation...
  templatepkg -a main
fi
if [ -d "$BASE_CONF/main.d" ]; then
  cd $BASE_CONF/main.d
  for file in `find`; do
    if [[ -f "$file" && -f "/$file" ]]; then
      if ! diff $file /$file; then
        echo updating $file
        cp -f /$file $file
      fi
    fi
  done
fi