source: src-sh/pc-extractoverlay/pc-extractoverlay @ 0dcd6a7

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

When we extract overlay on a desktop, check if correct beastie.4th menu is showing

  • Property mode set to 100755
File size: 4.2 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 correct beastie.4th menu is showing
60  grep -q 'pcbsd_boot="YES"' /boot/loader.conf
61  if [ $? -ne 0 ] ; then
62    # Enable the PC-BSD beastie.4th menu in /boot/loader.conf
63    echo "pcbsd_boot=\"YES\"" >> /boot/loader.conf
64  fi
65
66  post_extract_setup
67}
68
69do_server_overlay()
70{
71  distFile="/usr/local/share/pcbsd/distfiles/server-overlay.txz"
72  if [ "$sysinit" != "YES" ] ; then
73    excludeOpt="-X /usr/local/share/pcbsd/conf/server-excludes"
74  fi
75
76  echo -e "Extracting server overlay data...\c"
77  cd /
78  tar xvmf ${distFile} ${excludeOpt} 2>/dev/null
79  if [ $? -eq 0 ] ; then
80    echo -e "DONE"
81  else
82    echo -e "FAILED"
83    status="1"
84  fi
85  post_extract_setup
86}
87
88
89# Files we need to touch or change after an upgrade
90post_extract_setup()
91{
92  # Make sure rc.conf.pcbsd is enabled
93  grep -q 'rc.conf.pcbsd' /etc/defaults/rc.conf
94  if [ $? -ne 0 ] ; then
95    # Setup /etc/defaults/rc.conf
96    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
97    grep -q "rc.conf.pcbsd" /etc/defaults/rc.conf
98    if [ $? -ne 0 ] ; then
99      echo "WARNING: rc.conf.pcbsd not enabled in /etc/defaults/rc.conf"
100      status="1"
101    fi
102  fi
103
104  # Make sure loader.conf.pcbsd is enabled
105  grep -q 'loader.conf.pcbsd' /boot/defaults/loader.conf
106  if [ $? -ne 0 ] ; then
107    # Setup /boot/defaults/loader.conf
108    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
109    grep -q "loader.conf.pcbsd" /boot/defaults/loader.conf
110    if [ $? -ne 0 ] ; then
111      echo "WARNING: loader.conf.pcbsd not enabled in /boot/defaults/loader.conf"
112      status="1"
113    fi
114  fi
115
116  # See if we need to adjust pkg.conf
117  grep -q "ARCH" /usr/local/etc/pkg.conf
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.conf
122    if [ $? -ne 0 ] ; then
123       echo "WARNING: Failed setting VERSION in pkg.conf"
124       status="1"
125    fi
126    sed -i '' "s|ARCH|$ARCH|g" /usr/local/etc/pkg.conf
127    if [ $? -ne 0 ] ; then
128       echo "WARNING: Failed setting ARCH in pkg.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.