source: src-sh/pc-extractoverlay/pc-extractoverlay @ 04630fb

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

We don't need to keep changing /boot/defaults/loader.conf after extracting the overlay,
those files are setup in GRUB now

  • Property mode set to 100755
File size: 3.8 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  # See if we need to adjust pkg.conf
109  grep -q "ARCH" /usr/local/etc/pkg.conf
110  if [ $? -eq 0 ] ; then
111    ARCH=`uname -m`
112    FBSDVER=`uname -r | cut -d '-' -f 1-2`
113    sed -i '' "s|VERSION|$FBSDVER|g" /usr/local/etc/pkg.conf
114    if [ $? -ne 0 ] ; then
115       echo "WARNING: Failed setting VERSION in pkg.conf"
116       status="1"
117    fi
118    sed -i '' "s|ARCH|$ARCH|g" /usr/local/etc/pkg.conf
119    if [ $? -ne 0 ] ; then
120       echo "WARNING: Failed setting ARCH in pkg.conf"
121       status="1"
122    fi
123  fi
124}
125
126show_opts()
127{
128   cat << EOF
129
130usage: `basename $0` [options]
131               
132Options:
133  ports          -- Extract port overlay files
134  desktop        -- Extract desktop overlay files (Excluding user-configurable)
135  server         -- Extract server overlay files (Excluding user-configurable)
136  --sysinit      -- Overwrite user-configurable files (Used for first time init)
137
138EOF
139
140}
141
142# Set some defaults
143sysinit="no"
144status="0"
145
146# Parse CLI flags
147while [ $# -gt 0 ]; do
148   case "$1" in
149     desktop) target="desktop" ;;
150      server) target="server" ;;
151       ports) target="ports" ;;
152   --sysinit) sysinit="YES" ;;
153           *) echo "Invalid option $1 specified!"
154              show_opts
155              exit 1
156              ;;
157    esac
158    shift
159done
160
161# Now DO it
162case $target in
163    desktop) do_desktop_overlay ;;
164     server) do_server_overlay ;;
165      ports) do_ports_overlay ;;
166          *) show_opts ;;
167esac
168
169exit $status
Note: See TracBrowser for help on using the repository browser.