Project

General

Profile

Download (2.88 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2
#
3
# pfSense-nanobsd_to_fullinstall.sh
4
#
5
# part of pfSense (https://www.pfsense.org)
6
# Copyright (c) 2015-2016 Rubicon Communications, LLC (Netgate)
7
# All rights reserved.
8
#
9
# Licensed under the Apache License, Version 2.0 (the "License");
10
# you may not use this file except in compliance with the License.
11
# You may obtain a copy of the License at
12
#
13
# http://www.apache.org/licenses/LICENSE-2.0
14
#
15
# Unless required by applicable law or agreed to in writing, software
16
# distributed under the License is distributed on an "AS IS" BASIS,
17
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
# See the License for the specific language governing permissions and
19
# limitations under the License.
20

    
21
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
22

    
23
platform=$(cat /etc/platform)
24

    
25
if [ "${platform}" != "nanobsd" ]; then
26
	echo "ERROR: This script is supposed to run on a nanobsd installation"
27
	exit 1
28
fi
29

    
30
if [ "$(id -u)" != "0" ]; then
31
	echo "Please run as root/admin"
32
	exit 1
33
fi
34

    
35
cur_partition=$(mount -p / | cut -f1)
36

    
37
if ! echo "${cur_partition}" | grep -iq "pfsense0"; then
38
	echo "You are trying to run this script on a system that booted from"
39
	echo "secondary partition and it will not work."
40
	echo ""
41
	echo "On GUI, go to Diagnostics -> NanoBSD, duplicate primary slice"
42
	echo "to secondary and then Switch Bootup slice. Reboot the system"
43
	echo "and try again."
44

    
45
	exit 1
46
fi
47

    
48
update_partition=$(echo ${cur_partition} \
49
    | sed -e 's,0$,2,; s,1$,0,; s,2$,1,')
50

    
51
if [ ! -e "${update_partition}" ]; then
52
	echo "Secondary partition (${update_partition}) not found"
53
	exit 1
54
fi
55

    
56
# Remove /dev
57
update_partition=$(echo ${update_partition} | sed 's,^/dev/,,')
58
update_dev=$(glabel status -s \
59
    | awk "\$1 == \"${update_partition}\" { print \$3 }" | sed 's/s2a//')
60

    
61
if [ -z "${update_dev}" -o ! -e "/dev/${update_dev}" ]; then
62
	echo "Device (${update_dev}) not found"
63
	exit 1
64
fi
65

    
66
update_dev="/dev/${update_dev}"
67

    
68
cur_repo=/usr/local/etc/pkg/repos/pfSense.conf
69

    
70
/etc/rc.conf_mount_rw
71

    
72
if ! grep -q 'v2_4' $cur_repo; then
73
	next_repo=/usr/local/share/pfSense/pkg/repos/pfSense-repo-next.conf
74
	if [ ! -f $next_repo ]; then
75
		echo "Next Major version repository is missing"
76
		exit 1
77
	fi
78

    
79
	if [ "$(realpath $cur_repo)" != $next_repo ]; then
80
		echo "On GUI, go to System -> Update -> Update Settings and"
81
		echo "chose 'Next major version (2.4)' on 'Branch' option then"
82
		echo "try again"
83
		exit 1
84
	fi
85
fi
86

    
87
# Following commands must not fail
88
set -e
89

    
90
pkg set -y -o security/pfSense-base-nanobsd:security/pfSense-base \
91
    pfSense-base-nanobsd
92
pkg set -y -n pfSense-base-nanobsd:pfsense-base \
93
    pfSense-base-nanobsd
94

    
95
echo pfSense > /etc/platform
96

    
97
sed -i .bkp -e 's/ro,sync/rw/' /etc/fstab
98

    
99
gpart delete -i 2 ${update_dev}
100

    
101
touch /root/force_growfs
102

    
103
echo "Done. Your system was converted to a Full Install. Please upgrade it"
104
echo "immediately using console menu option 13 or calling pfSense-upgrade"
105
exit 0
(2-2/2)