Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
ce32fb74
Commit
ce32fb74
authored
Feb 27, 2017
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rc: move importer to very early spot, add timeout #1372
parent
21b84ed2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
42 deletions
+67
-42
rc
src/etc/rc
+6
-14
rc.bootup
src/etc/rc.bootup
+5
-25
rc.importer
src/etc/rc.importer
+56
-3
No files found.
src/etc/rc
View file @
ce32fb74
...
...
@@ -71,7 +71,7 @@ attempts=0
while
[
${
attempts
}
-lt
3
]
;
do
fsck
-C
-y
/
fsck
-C
-y
/
if
mount
-a
2>/dev/null
;
then
if
mount
-a
2>
/dev/null
;
then
# bail if all is well
break
fi
...
...
@@ -99,19 +99,11 @@ fi
# set keyboard map if needed
/etc/rc.d/syscons onestart
# set up config directory structure
mkdir
-p
/conf/backup
mkdir
-p
/conf/sshd
# Bootstrap config.xml if necessary
if
[
!
-f
/conf/config.xml
]
;
then
echo
-n
"Bootstrapping config.xml..."
cp
/usr/local/etc/config.xml /conf/config.xml
echo
"done."
fi
# run the config importer during early startup
/usr/local/etc/rc.importer
||
exit
1
# Enable console output if its muted.
/sbin/conscontrol mute off
>
/dev/null
/sbin/conscontrol mute off
>
/dev/null
setup_mfs_link
()
{
...
...
@@ -217,7 +209,7 @@ chmod 1777 /tmp
echo
-n
"."
/sbin/ldconfig
-elf
/usr/lib /usr/local/lib /lib
/etc/rc.d/ldconfig start 2>/dev/null
/etc/rc.d/ldconfig start 2>
/dev/null
# Launching kbdmux(4)
if
[
-f
"/dev/kbdmux0"
]
;
then
...
...
@@ -270,7 +262,7 @@ rm /var/run/booting
/usr/local/etc/rc.opnsense start
echo
-n
"Starting CRON..."
cd
/tmp
&&
/usr/sbin/cron
-s
2>/dev/null
cd
/tmp
&&
/usr/sbin/cron
-s
2>
/dev/null
echo
"done."
/usr/local/sbin/beep.sh start
...
...
src/etc/rc.bootup
View file @
ce32fb74
...
...
@@ -58,6 +58,10 @@ foreach ($inc_files as $inc_file) {
echo
"done.
\n
"
;
global
$config
;
$config
=
parse_config
(
true
);
convert_config
();
/*
* Now mute console messages from kernel for this script, it
* has consequences for printing bootup info and can clobber
...
...
@@ -65,30 +69,6 @@ echo "done.\n";
*/
system_console_mute
();
/* loopback device is required early for syslog and the installer */
interfaces_loopback_configure
(
true
);
$setup_installer
=
is_install_media
();
if
(
$setup_installer
)
{
echo
'Press any key to start the configuration importer: '
;
$key
=
timeout
();
if
(
$key
!=
"
\n
"
)
{
echo
"
\n
"
;
}
if
(
isset
(
$key
))
{
passthru
(
'/usr/local/etc/rc.importer'
);
}
/* config may have changed via installer import */
OPNsense\Core\Config
::
getInstance
()
->
forceReload
();
}
global
$config
;
$config
=
parse_config
(
true
);
convert_config
();
system_devd_configure
(
true
);
system_login_configure
(
true
);
...
...
@@ -158,7 +138,7 @@ if ($ipsec_dynamic_hosts) {
// generate configuration data for all installed templates
configd_run
(
'template reload *'
);
if
(
$setup_installer
)
{
if
(
is_install_media
()
)
{
/*
* Installer mode requires setting up an extra user and
* we will protect it with root's password. We can only
...
...
src/etc/rc.importer
View file @
ce32fb74
...
...
@@ -24,8 +24,57 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
INSTALL
=
"/.probe.for.install.media"
MNT
=
"/tmp/hdrescue"
bootstrap_and_exit
()
{
# ensure config directory structure
mkdir
-p
/conf/backup
mkdir
-p
/conf/sshd
# create initial config.xml if necessary
if
[
!
-f
/conf/config.xml
]
;
then
echo
-n
"Bootstrapping config.xml..."
cp
/usr/local/etc/config.xml /conf/config.xml
echo
"done."
fi
exit
0
}
touch
${
INSTALL
}
if
[
-f
${
INSTALL
}
-a
-f
/conf/config.xml
]
;
then
bootstrap_and_exit
fi
timeout_prompt
()
{
OUTPUT
=
$(
echo
${
2
}
|
sed
's/./& /g'
)
MESSAGE
=
${
1
}
RETURN
=
1
echo
-n
"
${
MESSAGE
}
"
stty
cbreak
-echo
for
NEXT
in
${
OUTPUT
}
;
do
echo
-n
${
NEXT
}
if
timeout
1
dd
of
=
/dev/null
count
=
1
status
=
none
;
then
RETURN
=
0
break
fi
done
stty
-cbreak
echo
echo
return
${
RETURN
}
}
if
!
timeout_prompt
'Press any key to start the configuration importer:'
.......
;
then
bootstrap_and_exit
fi
DEVS
=
$(
camcontrol devlist
)
PART
=
...
...
@@ -36,7 +85,7 @@ while [ -z "${PART}" ]; do
read
-p
"Select a device import from or leave blank to exit: "
DEV
if
[
-z
"
${
DEV
}
"
]
;
then
exit
0
bootstrap_and_exit
elif
[
-e
"/dev/
${
DEV
}
s1a"
]
;
then
# MBR layout found
PART
=
"/dev/
${
DEV
}
s1a"
...
...
@@ -59,14 +108,16 @@ if [ -f "${MNT}/conf/config.xml" ]; then
rm
-rf
/conf/
*
for
FILE
in
config.xml dhcpleases.tgz netflow.tgz rrd.tgz
;
do
if
[
-f
"
${
MNT
}
/conf/
${
FILE
}
"
]
;
then
echo
-n
"Restoring
${
FILE
}
..."
cp
"
${
MNT
}
/conf/
${
FILE
}
"
/conf
echo
"
Restored
${
FILE
}
"
echo
"
done.
"
fi
done
for
DIR
in
backup sshd
;
do
if
[
-d
"
${
MNT
}
/conf/
${
DIR
}
"
]
;
then
echo
-n
"Restoring
${
DIR
}
..."
cp
-r
"
${
MNT
}
/conf/
${
DIR
}
"
/conf
echo
"
Restored
${
DIR
}
"
echo
"
done.
"
else
mkdir
-p
"/conf/
${
DIR
}
"
fi
...
...
@@ -77,3 +128,5 @@ fi
umount
${
MNT
}
rm
-r
${
MNT
}
bootstrap_and_exit
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment