source: src-sh/pc-extractoverlay/pc-extractoverlay @ cbf97e7

9.2-release
Last change on this file since cbf97e7 was cbf97e7, checked in by Kris Moore <kris@…>, 11 months ago

Add '-p' to mkdir for pkgng revoked directory creation

  • Property mode set to 100755
File size: 4.1 KB
Line 
1#!/bin/sh
2
3do_prune()
4{
5  PRUNEFILE="/usr/local/share/pcbsd/conf/prune-port-files"
6  if [ ! -e "$PRUNEFILE" ] ; then return; fi
7       
8  while read pLine
9  do
10     if [ -z "${pLine}" ] ; then continue ; fi
11     echo $pLine | grep -q "^#"
12     if [ $? -eq 0 ] ; then continue ; fi
13
14     ls ${pLine} >/dev/null 2>/dev/null
15     if [ $? -eq 0 ] ; then
16        echo "Pruning: $pLine"
17        rm ${pLine}
18     fi
19  done <${PRUNEFILE}
20}
21
22do_ports_overlay()
23{
24
25  distFile="/usr/local/share/pcbsd/distfiles/port-overlay.txz"
26
27  # Cleanup any extra port cruft that doesn't place nice with PC-BSD
28  do_prune
29
30  # Since PKGNG requires this dir, but we can't ship an empty one
31  # with git, lets make sure it exists
32  if [ ! -d "/usr/local/etc/pkg/fingerprints/pcbsd/revoked" ] ; then
33     mkdir -p /usr/local/etc/pkg/fingerprints/pcbsd/revoked
34  fi
35
36  echo -e "Extracting ports overlay data...\c"
37  cd /
38  tar xvmf ${distFile} 2>/dev/null
39  if [ $? -eq 0 ] ; then
40    echo -e "DONE"
41    post_extract_setup
42    exit 0
43  else
44    echo -e "FAILED"
45    post_extract_setup
46    exit 1
47  fi
48}
49
50do_desktop_overlay()
51{
52  distFile="/usr/local/share/pcbsd/distfiles/desktop-overlay.txz"
53  if [ "$sysinit" != "YES" ] ; then
54    excludeOpt="-X /usr/local/share/pcbsd/conf/desktop-excludes"
55  fi
56
57  echo -e "Extracting desktop overlay data...\c"
58  cd /
59  tar xvmf ${distFile} ${excludeOpt} 2>/dev/null
60  if [ $? -eq 0 ] ; then
61    echo -e "DONE"
62  else
63    echo -e "FAILED"
64    status="1"
65  fi
66
67  # Make sure this system is flagged as a desktop
68  if [ ! -e "/etc/defaults/pcbsd" ] ; then
69     touch /etc/defaults/pcbsd
70  fi
71
72  post_extract_setup
73}
74
75do_server_overlay()
76{
77  distFile="/usr/local/share/pcbsd/distfiles/server-overlay.txz"
78  if [ "$sysinit" != "YES" ] ; then
79    excludeOpt="-X /usr/local/share/pcbsd/conf/server-excludes"
80  fi
81
82  echo -e "Extracting server overlay data...\c"
83  cd /
84  tar xvmf ${distFile} ${excludeOpt} 2>/dev/null
85  if [ $? -eq 0 ] ; then
86    echo -e "DONE"
87  else
88    echo -e "FAILED"
89    status="1"
90  fi
91
92  # Make sure this system is flagged as a server
93  if [ ! -e "/etc/defaults/trueos" ] ; then
94     touch /etc/defaults/trueos
95  fi
96
97  post_extract_setup
98}
99
100
101# Files we need to touch or change after an upgrade
102post_extract_setup()
103{
104  # Make sure rc.conf.pcbsd is enabled
105  grep -q 'rc.conf.pcbsd' /etc/defaults/rc.conf
106  if [ $? -ne 0 ] ; then
107    # Setup /etc/defaults/rc.conf
108    sed -i '' 's|/etc/rc.conf /etc/rc.conf.local|/etc/rc.conf.pcbsd /etc/rc.conf /etc/rc.conf.local|g' /etc/defaults/rc.conf 2>/dev/null
109    grep -q "rc.conf.pcbsd" /etc/defaults/rc.conf
110    if [ $? -ne 0 ] ; then
111      echo "WARNING: rc.conf.pcbsd not enabled in /etc/defaults/rc.conf"
112      status="1"
113    fi
114  fi
115
116  # See if we need to adjust pcbsd.conf repo file
117  grep -q "ARCH" /usr/local/etc/pkg/repos/pcbsd.conf 2>/dev/null
118  if [ $? -eq 0 ] ; then
119    ARCH=`uname -m`
120    FBSDVER=`uname -r | cut -d '-' -f 1-2`
121    sed -i '' "s|VERSION|$FBSDVER|g" /usr/local/etc/pkg/repos/pcbsd.conf
122    if [ $? -ne 0 ] ; then
123       echo "WARNING: Failed setting VERSION in pcbsd.conf"
124       status="1"
125    fi
126    sed -i '' "s|ARCH|$ARCH|g" /usr/local/etc/pkg/repos/pcbsd.conf
127    if [ $? -ne 0 ] ; then
128       echo "WARNING: Failed setting ARCH in pcbsd.conf"
129       status="1"
130    fi
131  fi
132}
133
134show_opts()
135{
136   cat << EOF
137
138usage: `basename $0` [options]
139               
140Options:
141  ports          -- Extract port overlay files
142  desktop        -- Extract desktop overlay files (Excluding user-configurable)
143  server         -- Extract server overlay files (Excluding user-configurable)
144  --sysinit      -- Overwrite user-configurable files (Used for first time init)
145
146EOF
147
148}
149
150# Set some defaults
151sysinit="no"
152status="0"
153
154# Parse CLI flags
155while [ $# -gt 0 ]; do
156   case "$1" in
157     desktop) target="desktop" ;;
158      server) target="server" ;;
159       ports) target="ports" ;;
160   --sysinit) sysinit="YES" ;;
161           *) echo "Invalid option $1 specified!"
162              show_opts
163              exit 1
164              ;;
165    esac
166    shift
167done
168
169# Now DO it
170case $target in
171    desktop) do_desktop_overlay ;;
172     server) do_server_overlay ;;
173      ports) do_ports_overlay ;;
174          *) show_opts ;;
175esac
176
177exit $status
Note: See TracBrowser for help on using the repository browser.