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
cf34abba
Commit
cf34abba
authored
Sep 09, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(firmware) change loader.conf.local generation, as discussed with @fichtner
parent
65653b7c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
92 deletions
+47
-92
rc.loader
src/etc/rc.loader
+44
-0
loader.py
src/opnsense/scripts/firmware/loader.py
+0
-78
actions_firmware.conf
src/opnsense/service/conf/actions.d/actions_firmware.conf
+3
-14
No files found.
src/etc/rc.loader
0 → 100755
View file @
cf34abba
#!/usr/local/bin/python2.7
# Copyright (c) 2016 Ad Schellevis
#
# 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 BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
import
os
import
glob
import
sys
loader_dir
=
"/usr/local/etc/rc.loader.d"
loader_conf_local
=
'/boot/loader.conf.local'
if
not
os
.
path
.
isdir
(
loader_dir
):
sys
.
exit
(
0
)
loader_conf_local_items
=
list
()
for
filename
in
glob
.
glob
(
'
%
s/*'
%
loader_dir
):
prop_name
=
os
.
path
.
basename
(
filename
)
prop_value
=
open
(
filename
,
'r'
)
.
read
()
.
strip
()
loader_conf_local_items
.
append
(
'
%
s="
%
s"'
%
(
prop_name
,
prop_value
))
# dump collected properies
open
(
loader_conf_local
,
'w'
)
.
write
(
'
%
s
\n
'
%
'
\n
'
.
join
(
loader_conf_local_items
))
src/opnsense/scripts/firmware/loader.py
deleted
100755 → 0
View file @
65653b7c
#!/usr/local/bin/python2.7
"""
Copyright (c) 2016 Ad Schellevis
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.
--------------------------------------------------------------------------------------
edit /boot/loader.conf.local
"""
import
sys
import
os
# parse parameters
cmd_switch
=
None
cmd_params
=
list
()
for
param
in
sys
.
argv
[
1
:]:
if
param
[
0
]
==
'-'
:
cmd_switch
=
param
[
1
:]
else
:
cmd_params
.
append
(
param
)
# load current loader.conf.local
if
os
.
path
.
isfile
(
'/boot/loader.conf.local'
):
current_loader_conf
=
open
(
'/boot/loader.conf.local'
,
'r'
)
.
read
()
else
:
current_loader_conf
=
''
# parse command switch
if
cmd_switch
==
's'
:
# -s : show current data
if
current_loader_conf
==
''
:
print
(
"(empty)"
)
else
:
print
(
current_loader_conf
)
elif
(
cmd_switch
==
'r'
and
len
(
cmd_params
)
==
1
)
or
(
cmd_switch
==
'e'
and
len
(
cmd_params
)
==
2
):
# -r remove, -e edit
new_loader_conf
=
[]
param_found
=
False
for
line
in
current_loader_conf
.
split
(
'
\n
'
):
if
line
.
strip
()
!=
""
:
param_parts
=
line
.
split
(
'='
)
if
param_parts
[
0
]
==
cmd_params
[
0
]:
if
cmd_switch
==
'e'
:
new_loader_conf
.
append
(
'
%
s="
%
s"'
%
tuple
(
cmd_params
))
param_found
=
True
else
:
new_loader_conf
.
append
(
line
)
if
not
param_found
and
cmd_switch
==
'e'
:
new_loader_conf
.
append
(
'
%
s="
%
s"'
%
tuple
(
cmd_params
))
open
(
'/boot/loader.conf.local'
,
'w'
)
.
write
(
'
\n
'
.
join
(
new_loader_conf
)
+
'
\n
'
)
else
:
# no (or illegal) command given, explain options
print
(
"usage
%
s -ser [parameter] [value]"
)
print
(
" -s show current loader.conf.local"
)
print
(
" -e edit/add loader.conf.local parameter"
)
print
(
" -r remove loader.conf.local parameter"
)
src/opnsense/service/conf/actions.d/actions_firmware.conf
View file @
cf34abba
...
...
@@ -95,20 +95,9 @@ parameters:
type
:
script
message
:
attempting
automatic
firmware
update
[
loader
.
show
]
command
:/
usr
/
local
/
opnsense
/
scripts
/
firmware
/
loader
.
py
-
s
[
loader
.
update
]
command
:/
usr
/
local
/
etc
/
rc
.
loader
parameters
:
type
:
script_output
message
:
show
user
specific
loader
commands
[
loader
.
edit
]
command
:/
usr
/
local
/
opnsense
/
scripts
/
firmware
/
loader
.
py
-
e
parameters
:%
s
%
s
type
:
script
message
:
edit
user
specific
loader
command
message
:
update
loader
.
conf
.
local
[
loader
.
rm
]
command
:/
usr
/
local
/
opnsense
/
scripts
/
firmware
/
loader
.
py
-
r
parameters
: %
s
type
:
script
message
:
remove
user
specific
loader
command
%
s
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