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

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

Make sure we set server/desktop markers, for those migrating from FreeBSD
to PC-BSD / TrueOS

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