functions-upgrade.sh (209552) | functions-upgrade.sh (211730) |
---|---|
1#!/bin/sh 2#- 3# Copyright (c) 2010 iXsystems, Inc. All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24# SUCH DAMAGE. 25# | 1#!/bin/sh 2#- 3# Copyright (c) 2010 iXsystems, Inc. All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24# SUCH DAMAGE. 25# |
26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh 209552 2010-06-27 16:46:11Z imp $ | 26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh 211730 2010-08-24 06:11:46Z imp $ |
27 28# Functions which perform the mounting / unmount for upgrades 29 30. ${PROGDIR}/backend/functions-unmount.sh 31 32mount_target_slice() 33{ 34 MPART="${1}" 35 36 # Import any zpools 37 zpool import -o altroot=${FSMNT} -a 38 umount_all_dir "${FSMNT}" 39 40 # Set a variable of files we want to make backups of before doing upgrade 41 BKFILES="/etc/rc.conf /boot/loader.conf" 42 43 if [ -e "/dev/${MPART}" ] ; then 44 rc_nohalt "mount /dev/${MPART} ${FSMNT}" 45 if [ "$?" != "0" ] ; then | 27 28# Functions which perform the mounting / unmount for upgrades 29 30. ${PROGDIR}/backend/functions-unmount.sh 31 32mount_target_slice() 33{ 34 MPART="${1}" 35 36 # Import any zpools 37 zpool import -o altroot=${FSMNT} -a 38 umount_all_dir "${FSMNT}" 39 40 # Set a variable of files we want to make backups of before doing upgrade 41 BKFILES="/etc/rc.conf /boot/loader.conf" 42 43 if [ -e "/dev/${MPART}" ] ; then 44 rc_nohalt "mount /dev/${MPART} ${FSMNT}" 45 if [ "$?" != "0" ] ; then |
46 # Check if we have ZFS tank name 47 rc_halt "mount -t zfs ${MPART} ${FSMNT}" | 46 # Check if we have ZFS tank name 47 rc_halt "mount -t zfs ${MPART} ${FSMNT}" |
48 fi 49 else 50 # Check if we have ZFS tank name 51 rc_halt "mount -t zfs ${MPART} ${FSMNT}" 52 fi 53 54 # Mount devfs in chroot 55 mount -t devfs devfs ${FSMNT}/dev --- 43 unchanged lines hidden (view full) --- 99 run_chroot_cmd "rm -rf /usr/bin" >/dev/null 2>/dev/null 100 run_chroot_cmd "rm -rf /boot/kernel" >/dev/null 2>/dev/null 101 run_chroot_cmd "rm -rf /sbin" >/dev/null 2>/dev/null 102 run_chroot_cmd "rm -rf /bin" >/dev/null 2>/dev/null 103 run_chroot_cmd "rm -rf /lib" >/dev/null 2>/dev/null 104 run_chroot_cmd "rm -rf /libexec" >/dev/null 2>/dev/null 105 fi 106 | 48 fi 49 else 50 # Check if we have ZFS tank name 51 rc_halt "mount -t zfs ${MPART} ${FSMNT}" 52 fi 53 54 # Mount devfs in chroot 55 mount -t devfs devfs ${FSMNT}/dev --- 43 unchanged lines hidden (view full) --- 99 run_chroot_cmd "rm -rf /usr/bin" >/dev/null 2>/dev/null 100 run_chroot_cmd "rm -rf /boot/kernel" >/dev/null 2>/dev/null 101 run_chroot_cmd "rm -rf /sbin" >/dev/null 2>/dev/null 102 run_chroot_cmd "rm -rf /bin" >/dev/null 2>/dev/null 103 run_chroot_cmd "rm -rf /lib" >/dev/null 2>/dev/null 104 run_chroot_cmd "rm -rf /libexec" >/dev/null 2>/dev/null 105 fi 106 |
107} | 107}; |
108 109# Mount the target upgrade partitions 110mount_upgrade() 111{ 112 113 # Make sure we remove the old upgrade-mount script 114 rm -rf ${TMPDIR}/.upgrade-unmount >/dev/null 2>/dev/null 115 116 # We are ready to start mounting, lets read the config and do it 117 while read line 118 do | 108 109# Mount the target upgrade partitions 110mount_upgrade() 111{ 112 113 # Make sure we remove the old upgrade-mount script 114 rm -rf ${TMPDIR}/.upgrade-unmount >/dev/null 2>/dev/null 115 116 # We are ready to start mounting, lets read the config and do it 117 while read line 118 do |
119 echo $line | grep "^disk0=" >/dev/null 2>/dev/null 120 if [ "$?" = "0" ] 121 then | 119 echo $line | grep "^disk0=" >/dev/null 2>/dev/null 120 if [ "$?" = "0" ] 121 then |
122 | 122 |
123 # Found a disk= entry, lets get the disk we are working on 124 get_value_from_string "${line}" 125 strip_white_space "$VAL" 126 DISK="$VAL" 127 fi | 123 # Found a disk= entry, lets get the disk we are working on 124 get_value_from_string "${line}" 125 strip_white_space "$VAL" 126 DISK="$VAL" 127 fi |
128 | 128 |
129 echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null 130 if [ "$?" = "0" ] 131 then 132 # Found our flag to commit this disk setup / lets do sanity check and do it 133 if [ ! -z "${DISK}" ] 134 then | 129 echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null 130 if [ "$?" = "0" ] 131 then 132 # Found our flag to commit this disk setup / lets do sanity check and do it 133 if [ ! -z "${DISK}" ] 134 then |
135 | 135 |
136 # Start mounting this slice 137 mount_target_slice "${DISK}" | 136 # Start mounting this slice 137 mount_target_slice "${DISK}" |
138 | 138 |
139 # Increment our disk counter to look for next disk and unset 140 unset DISK 141 break 142 else 143 exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!" 144 fi 145 fi | 139 # Increment our disk counter to look for next disk and unset 140 unset DISK 141 break 142 else 143 exit_err "ERROR: commitDiskPart was called without procceding disk 144 fi 145 fi |
146 147 done <${CFGF} 148 149}; 150 151copy_skel_files_upgrade() 152{ 153 | 146 147 done <${CFGF} 148 149}; 150 151copy_skel_files_upgrade() 152{ 153 |
154 # Now make sure we fix any user profile scripts, which cause problems from 7.x->8.x 155 echo '#!/bin/sh | 154 # Now make sure we fix any user profile scripts, which cause problems from 7.x->8.x 155 echo '#!/bin/sh |
156 157cd /home 158for i in `ls` 159do 160 161 # Backup the old profile dirs 162 if [ -d "${i}" ] 163 then --- 10 unchanged lines hidden (view full) --- 174 cp /usr/share/skel/${j} /home/${i}/${dname} 175 done 176 177 chown -R ${i}:${i} /home/${i} 178 fi 179 180done 181' >${FSMNT}/.fixUserProfile.sh | 156 157cd /home 158for i in `ls` 159do 160 161 # Backup the old profile dirs 162 if [ -d "${i}" ] 163 then --- 10 unchanged lines hidden (view full) --- 174 cp /usr/share/skel/${j} /home/${i}/${dname} 175 done 176 177 chown -R ${i}:${i} /home/${i} 178 fi 179 180done 181' >${FSMNT}/.fixUserProfile.sh |
182 chmod 755 ${FSMNT}/.fixUserProfile.sh 183 chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null 184 rm ${FSMNT}/.fixUserProfile.sh | 182 chmod 755 ${FSMNT}/.fixUserProfile.sh 183 chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null 184 rm ${FSMNT}/.fixUserProfile.sh |
185 186 187 | 185 186 187 |
188 # if the user wants to keep their original .kde4 profile 189 ########################################################################### 190 get_value_from_cfg "upgradeKeepDesktopProfile" 191 if [ "$VAL" = "YES" -o "$VAL" = "yes" ] ; then 192 echo '#!/bin/sh | 188 # if the user wants to keep their original .kde4 profile 189 ########################################################################### 190 get_value_from_cfg "upgradeKeepDesktopProfile" 191 if [ "$VAL" = "YES" -o "$VAL" = "yes" ] ; then 192 echo '#!/bin/sh |
193 cd /home 194for i in `ls` 195do 196 # Import the old config again 197 if [ -d "${i}/.kde4.preUpgrade" ] 198 then 199 # Copy over the skel directories 200 tar cv -f - -C /home/${i}/.kde4.preUpgrade . 2>/dev/null | tar xvf - -C /home/${i}/.kde4 2>/dev/null 201 chown -R ${i}:${i} /home/${i}/.kde4 202 fi 203done 204' >${FSMNT}/.fixUserProfile.sh | 193 cd /home 194for i in `ls` 195do 196 # Import the old config again 197 if [ -d "${i}/.kde4.preUpgrade" ] 198 then 199 # Copy over the skel directories 200 tar cv -f - -C /home/${i}/.kde4.preUpgrade . 2>/dev/null | tar xvf - -C /home/${i}/.kde4 2>/dev/null 201 chown -R ${i}:${i} /home/${i}/.kde4 202 fi 203done 204' >${FSMNT}/.fixUserProfile.sh |
205 chmod 755 ${FSMNT}/.fixUserProfile.sh 206 chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null 207 rm ${FSMNT}/.fixUserProfile.sh | 205 chmod 755 ${FSMNT}/.fixUserProfile.sh 206 chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null 207 rm ${FSMNT}/.fixUserProfile.sh |
208 | 208 |
209 fi | 209 fi |
210 211}; 212 213# Function which merges some configuration files with the new defaults 214merge_old_configs() 215{ 216 217 # Merge the loader.conf with old --- 7 unchanged lines hidden (view full) --- 225 rm ${FSMNT}/etc/rc.conf.new 226 227}; 228 229# Function which unmounts all the mounted file-systems 230unmount_upgrade() 231{ 232 | 210 211}; 212 213# Function which merges some configuration files with the new defaults 214merge_old_configs() 215{ 216 217 # Merge the loader.conf with old --- 7 unchanged lines hidden (view full) --- 225 rm ${FSMNT}/etc/rc.conf.new 226 227}; 228 229# Function which unmounts all the mounted file-systems 230unmount_upgrade() 231{ 232 |
233 # If on PC-BSD, make sure we copy any fixed skel files 234 if [ "$INSTALLTYPE" != "FreeBSD" ] ; then 235 copy_skel_files_upgrade 236 fi | 233 # If on PC-BSD, make sure we copy any fixed skel files 234 if [ "$INSTALLTYPE" != "FreeBSD" ] ; then 235 copy_skel_files_upgrade 236 fi |
237 | 237 |
238 cd / | 238 cd / |
239 | 239 |
240 # Unmount FS 241 umount_all_dir "${FSMNT}" | 240 # Unmount FS 241 umount_all_dir "${FSMNT}" |
242 | 242 |
243 # Run our saved unmount script for these file-systems 244 rc_nohalt "umount -f ${FSMNT}" | 243 # Run our saved unmount script for these file-systems 244 rc_nohalt "umount -f ${FSMNT}" |
245 | 245 |
246 umount ${CDMNT} | 246 umount ${CDMNT} |
247}; | 247}; |