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
aa05ce18
Commit
aa05ce18
authored
Mar 19, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unused / buggy firmware upgrade bits and pieces.
parent
c30080e5
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
724 deletions
+0
-724
rc.create_full_backup
src/etc/rc.create_full_backup
+0
-18
rc.firmware
src/etc/rc.firmware
+0
-209
system_firmware.php
src/www/system_firmware.php
+0
-295
system_firmware_restorefullbackup.php
src/www/system_firmware_restorefullbackup.php
+0
-202
No files found.
src/etc/rc.create_full_backup
deleted
100755 → 0
View file @
c30080e5
#!/bin/sh
FILENAME
=
"pfSense-full-backup-
`
date
"+%Y%m%d-%H%M"
`
.tgz"
echo
">>> Creating full backup to /root/
$FILENAME
"
tar
czPf /root/
$FILENAME
\
--exclude
dev/
*
\
--exclude
tmp/
*
\
--exclude
var/db
\
--exclude
var/run/
*
\
--exclude
root/
*
\
--exclude
var/empty/
*
\
--exclude
var/empty
\
--exclude
var/etc
\
/
echo
">>> Backup completed. Note: this backup includes config.xml!"
echo
">>> To restore this backup run this command:"
echo
" /usr/local/etc/rc.restore_full_backup /root/
$FILENAME
"
src/etc/rc.firmware
deleted
100755 → 0
View file @
c30080e5
#!/bin/sh
# originally part of m0n0wall (http://neon1.net/m0n0wall)
# Copyright (C) 2005-2009 Scott Ullrich <sullrich@pfsense.org>.
# Copyright (C) 2003 Manuel Kasper <mk@neon1.net>.
# All rights reserved.
# mount /cf
/usr/local/etc/rc.conf_mount_rw
# Reset file(s)
echo
""
>
/conf/upgrade_log.txt
echo
""
>
/conf/firmware_update_misc_log.txt
echo
""
>
/conf/fdisk_upgrade_log.txt
exec
3>&2 2>>/conf/firmware_update_misc_log.txt
export
ACTION
=
$1
export
IMG
=
$2
if
[
$#
-eq
3
]
;
then
export
CUSTOMIMG
=
$3
fi
if
[
$ACTION
!=
"upgrade"
]
;
then
/sbin/umount
-f
/ftmp
>
/dev/null 2>&1
fi
file_notice
()
{
/usr/local/bin/php
-q
-d
auto_prepend_file
=
config.inc
<<
ENDOFF
<?php
require_once("globals.inc");
require_once("functions.inc");
file_notice("
$1
", "
$2
", "
$1
", "");
?>
ENDOFF
}
output_env_to_log
()
{
date
>>
/conf/upgrade_log.txt
echo
""
>>
/conf/upgrade_log.txt
ls
-lah
/dev/
>>
/conf/upgrade_log.txt
echo
""
>>
/conf/upgrade_log.txt
ls
-lah
$IMG
>>
/conf/upgrade_log.txt
echo
""
>>
/conf/upgrade_log.txt
md5
$IMG
>>
/conf/upgrade_log.txt
echo
""
>>
/conf/upgrade_log.txt
mount
>>
/conf/upgrade_log.txt
echo
""
>>
/conf/upgrade_log.txt
top
>>
/conf/upgrade_log.txt
echo
""
>>
/conf/upgrade_log.txt
}
backup_chflags
()
{
TOPROCESS
=
"bin lib libexec sbin usr"
for
files
in
$TOPROCESS
;
do
/usr/sbin/mtree
-Pcp
/
${
files
}
| bzip2
-9
>
/tmp/chflags.dist.
${
files
}
.bz2 2>> /conf/upgrade_log.txt
done
}
restore_chflags
()
{
TOPROCESS
=
"bin lib libexec sbin usr"
for
files
in
$TOPROCESS
;
do
cd
/
&&
/usr/bin/bzcat /tmp/chflags.dist.
${
files
}
.bz2 | /usr/sbin/mtree
-PU
-p
/
${
files
}
>>
/conf/upgrade_log.txt 2>&1
done
}
remove_chflags
()
{
TOPROCESS
=
"bin lib libexec sbin usr"
for
files
in
$TOPROCESS
;
do
/bin/chflags
-R
noschg /
${
files
}
/bin/chmod
-R
u+rw /
${
files
}
done
}
case
$ACTION
in
pfSenseupgrade
)
# Sanity check - bail early if there's no firmware file!
if
[
!
-r
$IMG
]
;
then
echo
"2nd parameter has not been passed or file does not exist. Exiting."
>>
/conf/upgrade_log.txt 2>&1
/usr/local/etc/rc.conf_mount_ro
exit
fi
# wait 1 seconds before beginning
sleep
1
# Log that we are really doing a pfSense upgrade
echo
""
>>
/conf/upgrade_log.txt
echo
"pfSenseupgrade upgrade starting"
>>
/conf/upgrade_log.txt
echo
""
>>
/conf/upgrade_log.txt
touch
/var/run/firmwarelock.dirty
if
[
-f
/tmp/perform_full_backup.txt
]
;
then
echo
"Performing full backup"
>>
/conf/upgrade_log.txt
/usr/local/etc/rc.create_full_backup
rm
/tmp/perform_full_backup.txt
fi
touch
/conf/upgrade_log.txt
echo
""
>>
/conf/upgrade_log.txt
# Output environment information to log file
output_env_to_log
backup_chflags
remove_chflags
# Do we have a pre-upgrade hook in the update file?
if
[
`
tar
tvzf
$IMG
|
grep
/tmp/pre_upgrade_command |
wc
-l
`
-gt
0
]
;
then
tar
xzvf
$IMG
-C
/ ./tmp/pre_upgrade_command
>>
/conf/upgrade_log.txt 2>&1
chmod
a+rx /tmp/pre_upgrade_command
>>
/conf/upgrade_log.txt 2>&1
sh /tmp/pre_upgrade_command
>>
/conf/upgrade_log.txt 2>&1
fi
echo
"Firmware upgrade in progress..."
>>
/conf/upgrade_log.txt 2>&1
echo
"Firmware upgrade in progress..."
| wall
/usr/local/etc/rc.notify_message
-e
-g
-m
"Firmware upgrade in progress..."
# backup config
[
-d
/tmp/configbak
]
&&
rm
-rf
/tmp/configbak
/bin/mkdir
-p
/tmp/configbak
cp
-Rp
/conf/
*
/tmp/configbak 2>/dev/null
# Remove logs from backup dir to avoid clobbering upon restore.
rm
/tmp/configbak/
*
_log.txt 2>/dev/null
# tar explode image onto hd
ps
-a
|
grep
"configd"
|
awk
'{print $1;}'
|
kill
-9
echo
"Installing
$IMG
."
>>
/conf/upgrade_log.txt 2>&1
cd
/
&&
/usr/bin/tar
--exclude
=
./dev
-xzUPf
$IMG
>>
/conf/upgrade_log.txt 2>&1
/usr/local/opnsense/service/configd.py
echo
"Image installed
$IMG
."
>>
/conf/upgrade_log.txt 2>&1
# process custom image if its passed
if
[
$#
-eq
3
]
;
then
if
[
-f
$CUSTOMIMG
]
;
then
echo
"Custom image
$CUSTOMIMG
found."
>>
/conf/upgrade_log.txt 2>&1
echo
"Custom image (
$CUSTOMIMG
) found."
>>
/conf/upgrade_log.txt 2>&1
PWD_DIR
=
`
pwd
`
cd
/
&&
/usr/bin/tar xzPUf
$CUSTOMIMG
>>
/conf/upgrade_log.txt 2>&1
cd
$PWD_DIR
echo
"Custom image
$CUSTOMIMG
installed."
>>
/conf/upgrade_log.txt 2>&1
fi
fi
# restore config
cp
-Rp
/tmp/configbak/
*
/conf 2>/dev/null
# restore /etc symlinks
rm
/etc/hosts
ln
-s
/var/etc/hosts /etc/hosts
restore_chflags
# Remove upgrade file
rm
-f
$IMG
if
[
-e
/etc/init_bootloader.sh
]
;
then
if
[
!
-x
/etc/init_bootloader.sh
]
;
then
chmod
ug+x /etc/init_bootloader.sh
fi
/etc/init_bootloader.sh
>>
/conf/upgrade_log.txt 2>&1
fi
# If /tmp/post_upgrade_command exists after update
# then execute the command.
if
[
-f
/tmp/post_upgrade_command
]
;
then
if
[
!
-x
/tmp/post_upgrade_command
]
;
then
chmod
ug+x /tmp/post_upgrade_command
fi
/tmp/post_upgrade_command
>>
/conf/upgrade_log.txt 2>&1
fi
date
>>
/conf/upgrade_log.txt
echo
""
>>
/conf/upgrade_log.txt
# remount /cf ro
/usr/local/etc/rc.conf_mount_ro
# release the firmware lock
rm
-f
/var/run/firmwarelock.dirty
rm
-f
/var/run/firmware.lock
/bin/sync
echo
"Firmware upgrade is complete. Rebooting in 10 seconds."
>>
/conf/upgrade_log.txt 2>&1
echo
"Firmware upgrade is complete. Rebooting in 10 seconds."
| wall
/usr/local/etc/rc.notify_message
-e
-g
-m
"Firmware upgrade is complete. Rebooting in 10 seconds."
# Sleep and allow disks to catch up
sleep
10
# If the archive has unpacked a file called
# /tmp/no_upgrade_reboot_required then do
# not reboot after upgrade.
if
[
-f
/tmp/no_upgrade_reboot_required
]
;
then
rm
/tmp/no_upgrade_reboot_required
else
.
/usr/local/etc/rc.reboot
fi
;;
esac
src/www/system_firmware.php
deleted
100644 → 0
View file @
c30080e5
This diff is collapsed.
Click to expand it.
src/www/system_firmware_restorefullbackup.php
deleted
100644 → 0
View file @
c30080e5
<?php
/*
Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2011 Scott Ullrich
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/* Allow additional execution time 0 = no limit. */
ini_set
(
'max_execution_time'
,
'0'
);
ini_set
(
'max_input_time'
,
'0'
);
require_once
(
"functions.inc"
);
require
(
"guiconfig.inc"
);
require_once
(
"filter.inc"
);
require_once
(
"shaper.inc"
);
if
(
$_POST
[
'overwriteconfigxml'
])
touch
(
"/tmp/do_not_restore_config.xml"
);
if
(
$_GET
[
'backupnow'
])
mwexec_bg
(
"/usr/local/etc/rc.create_full_backup"
);
if
(
$_GET
[
'downloadbackup'
])
{
$filename
=
basename
(
$_GET
[
'downloadbackup'
]);
$path
=
"/root/
{
$filename
}
"
;
if
(
file_exists
(
$path
))
{
session_write_close
();
ob_end_clean
();
session_cache_limiter
(
'public'
);
//$fd = fopen("/root/{$filename}", "rb");
$filesize
=
filesize
(
"/root/
{
$filename
}
"
);
header
(
"Cache-Control: "
);
header
(
"Pragma: "
);
header
(
"Content-Type: application/octet-stream"
);
header
(
"Content-Length: "
.
(
string
)(
filesize
(
$path
))
);
header
(
'Content-Disposition: attachment; filename="'
.
$filename
.
'"'
);
header
(
"Content-Transfer-Encoding: binary
\n
"
);
if
(
$file
=
fopen
(
"/root/
{
$filename
}
"
,
'rb'
)){
while
(
(
!
feof
(
$file
))
&&
(
connection_status
()
==
0
)
){
print
(
fread
(
$file
,
1024
*
8
));
flush
();
}
fclose
(
$file
);
}
exit
;
}
}
if
(
$_GET
[
'deletefile'
])
{
$filename
=
$_GET
[
'deletefile'
];
if
(
file_exists
(
"/root/
{
$filename
}
"
))
{
unlink
(
"/root/"
.
$filename
);
$savemsg
=
gettext
(
"
$filename
has been deleted."
);
}
}
if
(
$_POST
[
'restorefile'
])
{
$filename
=
$_POST
[
'restorefile'
];
if
(
file_exists
(
"/root/
{
$filename
}
"
))
{
mwexec_bg
(
"/usr/local/etc/rc.restore_full_backup /root/"
.
escapeshellcmd
(
$filename
));
$savemsg
=
gettext
(
"The firewall is currently restoring
$filename
"
);
}
}
$pgtitle
=
array
(
gettext
(
"Diagnostics"
),
gettext
(
"Restore full backup"
));
include
(
"head.inc"
);
?>
<body>
<?php
include
(
"fbegin.inc"
);
?>
<!-- row -->
<section
class=
"page-content-main"
>
<div
class=
"container-fluid"
>
<div
class=
"row"
>
<?php
if
(
$input_errors
)
print_input_errors
(
$input_errors
);
if
(
$savemsg
)
print_info_box
(
$savemsg
);
?>
<section
class=
"col-xs-12"
>
<?
include
(
'system_firmware_tabs.php'
);
?>
<div
class=
"content-box tab-content"
>
<?php
if
(
is_subsystem_dirty
(
'restore'
))
:
?>
<p>
<form
action=
"reboot.php"
method=
"post"
>
<input
name=
"Submit"
type=
"hidden"
value=
"Yes"
/>
<?php
print_info_box
(
gettext
(
"The firewall configuration has been changed."
)
.
"<br />"
.
gettext
(
"The firewall is now rebooting."
));
?>
<br
/>
</form>
<?php
endif
;
?>
<form
action=
"system_firmware_restorefullbackup.php"
method=
"post"
>
<table
class=
"table table-striped __nomb"
align=
"center"
width=
"100%"
border=
"0"
cellpadding=
"6"
cellspacing=
"0"
summary=
"main area"
>
<thead>
<tr>
<th
colspan=
"1"
class=
"listtopic"
>
<?=
gettext
(
"Filename"
);
?>
</th>
<th
colspan=
"1"
class=
"listtopic"
>
<?=
gettext
(
"Date"
);
?>
</th>
<th
colspan=
"2"
class=
"listtopic"
>
<?=
gettext
(
"Size"
);
?>
</th>
</tr>
</thead>
<tbody>
<?php
chdir
(
"/root"
);
$available_restore_files
=
glob
(
"pfSense-full-backup-*"
);
$counter
=
0
;
foreach
(
$available_restore_files
as
$arf
)
{
$counter
++
;
$size
=
exec
(
"gzip -l /root/
$arf
| grep -v compressed | awk '{ print $2 }'"
);
echo
"<tr>"
;
echo
"<td class='listlr' width='50%' colspan='1'>"
;
echo
"<input type='radio' name='restorefile' value='
$arf
' />
$arf
"
;
echo
"</td>"
;
echo
"<td class='listr' width='30%' colspan='1'>"
;
echo
date
(
"F d Y H:i:s"
,
filemtime
(
$arf
));
echo
"</td>"
;
echo
"<td class='listr' width='40%' colspan='1'>"
;
echo
format_bytes
(
$size
);
echo
"</td>"
;
echo
"<td class='listr nowrap' width='20%' colspan='1'>"
;
echo
"<a onclick=
\"
return confirm('"
.
gettext
(
"Do you really want to delete this backup?"
)
.
"')
\"
href='system_firmware_restorefullbackup.php?deletefile="
.
htmlspecialchars
(
$arf
)
.
"'>"
;
echo
gettext
(
"Delete"
);
echo
"</a> | "
;
echo
"<a href='system_firmware_restorefullbackup.php?downloadbackup="
.
htmlspecialchars
(
$arf
)
.
"'>"
;
echo
gettext
(
"Download"
);
echo
"</a>"
;
echo
"</td>"
;
echo
"</tr>"
;
}
if
(
$counter
==
0
)
{
echo
"<tr>"
;
echo
"<td class='listlr' width='100%' colspan='4' align='center'>"
;
echo
gettext
(
"Could not locate any previous backups."
);
echo
"</td>"
;
echo
"</tr>"
;
}
?>
<tr>
<td
width=
"78%"
colspan=
"3"
>
<br
/>
<input
type=
"checkbox"
name=
"overwriteconfigxml"
id=
"overwriteconfigxml"
checked=
"checked"
/>
<?=
gettext
(
"do not restore config.xml."
);
?>
<br
/>
<input
name=
"Restore"
type=
"submit"
class=
"btn btn-primary"
id=
"restore"
value=
"
<?=
gettext
(
"Restore"
);
?>
"
/>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</section>
</div>
</div>
</section>
<script
type=
"text/javascript"
>
//
<!
[
CDATA
[
encrypt_change
();
decrypt_change
();
//]]>
</script>
<?php
include
(
"foot.inc"
);
?>
<?php
if
(
is_subsystem_dirty
(
'restore'
))
system_reboot
();
?>
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