source: src-sh/pc-extractoverlay/pc-extractoverlay @ 2ee61e0

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since 2ee61e0 was 2ee61e0, checked in by Kris Moore <kris@…>, 12 months ago

Don't need to set pcbsd_boot in loader.conf anymore

  • Property mode set to 100755
File size: 4.3 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  echo -e "Extracting ports overlay data...\c"
31  cd /
32  tar xvmf ${distFile} 2>/dev/null
33  if [ $? -eq 0 ] ; then
34    echo -e "DONE"
35    exit 0
36  else
37    echo -e "FAILED"
38    exit 1
39  fi
40}
41
42do_desktop_overlay()
43{
44  distFile="/usr/local/share/pcbsd/distfiles/desktop-overlay.txz"
45  if [ "$sysinit" != "YES" ] ; then
46    excludeOpt="-X /usr/local/share/pcbsd/conf/desktop-excludes"
47  fi
48
49  echo -e "Extracting desktop overlay data...\c"
50  cd /
51  tar xvmf ${distFile} ${excludeOpt} 2>/dev/null
52  if [ $? -eq 0 ] ; then
53    echo -e "DONE"
54  else
55    echo -e "FAILED"
56    status="1"
57  fi
58
59  # Make sure this system is flagged as a desktop
60  if [ ! -e "/etc/defaults/pcbsd" ] ; then
61     touch /etc/defaults/pcbsd
62  fi
63
64  post_extract_setup
65}
66
67do_server_overlay()
68{
69  distFile="/usr/local/share/pcbsd/distfiles/server-overlay.txz"
70  if [ "$sysinit" != "YES" ] ; then
71    excludeOpt="-X /usr/local/share/pcbsd/conf/server-excludes"
72  fi
73
74  echo -e "Extracting server overlay data...\c"
75  cd /
76  tar xvmf ${distFile} ${excludeOpt} 2>/dev/null
77  if [ $? -eq 0 ] ; then
78    echo -e "DONE"
79  else
80    echo -e "FAILED"
81    status="1"
82  fi
83
84  # Make sure this system is flagged as a server
85  if [ ! -e "/etc/defaults/trueos" ] ; then
86     touch /etc/defaults/trueos
87  fi
88
89  post_extract_setup
90}
91
92
93# Files we need to touch or change after an upgrade
94post_extract_setup()
95{
96  # Make sure rc.conf.pcbsd is enabled
97  grep -q 'rc.conf.pcbsd' /etc/defaults/rc.conf
98  if [ $? -ne 0 ] ; then
99    # Setup /etc/defaults/rc.conf
100    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
101    grep -q "rc.conf.pcbsd" /etc/defaults/rc.conf
102    if [ $? -ne 0 ] ; then
103      echo "WARNING: rc.conf.pcbsd not enabled in /etc/defaults/rc.conf"
104      status="1"
105    fi
106  fi
107
108  # Make sure loader.conf.pcbsd is enabled
109  grep -q 'loader.conf.pcbsd' /boot/defaults/loader.conf
110  if [ $? -ne 0 ] ; then
111    # Setup /boot/defaults/loader.conf
112    sed -i '' 's|/boot/loader.conf /boot/loader.conf.local|/boot/loader.conf.pcbsd /boot/loader.conf /boot/loader.conf.local|g' /boot/defaults/loader.conf 2>/dev/null
113    grep -q "loader.conf.pcbsd" /boot/defaults/loader.conf
114    if [ $? -ne 0 ] ; then
115      echo "WARNING: loader.conf.pcbsd not enabled in /boot/defaults/loader.conf"
116      status="1"
117    fi
118  fi
119
120  # See if we need to adjust pkg.conf
121  grep -q "ARCH" /usr/local/etc/pkg.conf
122  if [ $? -eq 0 ] ; then
123    ARCH=`uname -m`
124    FBSDVER=`uname -r | cut -d '-' -f 1-2`
125    sed -i '' "s|VERSION|$FBSDVER|g" /usr/local/etc/pkg.conf
126    if [ $? -ne 0 ] ; then
127       echo "WARNING: Failed setting VERSION in pkg.conf"
128       status="1"
129    fi
130    sed -i '' "s|ARCH|$ARCH|g" /usr/local/etc/pkg.conf
131    if [ $? -ne 0 ] ; then
132       echo "WARNING: Failed setting ARCH in pkg.conf"
133       status="1"
134    fi
135  fi
136}
137
138show_opts()
139{
140   cat << EOF
141
142usage: `basename $0` [options]
143               
144Options:
145  ports          -- Extract port overlay files
146  desktop        -- Extract desktop overlay files (Excluding user-configurable)
147  server         -- Extract server overlay files (Excluding user-configurable)
148  --sysinit      -- Overwrite user-configurable files (Used for first time init)
149
150EOF
151
152}
153
154# Set some defaults
155sysinit="no"
156status="0"
157
158# Parse CLI flags
159while [ $# -gt 0 ]; do
160   case "$1" in
161     desktop) target="desktop" ;;
162      server) target="server" ;;
163       ports) target="ports" ;;
164   --sysinit) sysinit="YES" ;;
165           *) echo "Invalid option $1 specified!"
166              show_opts
167              exit 1
168              ;;
169    esac
170    shift
171done
172
173# Now DO it
174case $target in
175    desktop) do_desktop_overlay ;;
176     server) do_server_overlay ;;
177      ports) do_ports_overlay ;;
178          *) show_opts ;;
179esac
180
181exit $status
Note: See TracBrowser for help on using the repository browser.