Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
83
Issues
83
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
8ca5bb52
Commit
8ca5bb52
authored
Jun 25, 2019
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Plain Diff
[Feature
#72
] Make starting scripts to print to syslog
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parents
78aa9559
1b5de95b
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
59 additions
and
37 deletions
+59
-37
dot-config
userspace/rootfs_override/etc/init.d/dot-config
+19
-12
hwinfo
userspace/rootfs_override/etc/init.d/hwinfo
+4
-2
network
userspace/rootfs_override/etc/init.d/network
+12
-9
nslcd.sh
userspace/rootfs_override/etc/init.d/nslcd.sh
+8
-7
apply_dot-config
userspace/rootfs_override/wr/bin/apply_dot-config
+5
-3
assembly_ppsi_conf.sh
userspace/rootfs_override/wr/bin/assembly_ppsi_conf.sh
+5
-4
dhcp_extra_opt.sh
userspace/rootfs_override/wr/bin/dhcp_extra_opt.sh
+4
-0
rsyslog.conf.in
userspace/rootfs_override/wr/etc/rsyslog.conf.in
+2
-0
No files found.
userspace/rootfs_override/etc/init.d/dot-config
View file @
8ca5bb52
...
...
@@ -9,6 +9,13 @@
dotconfig
=
/wr/etc/dot-config
tmpconfig
=
/tmp/dot-config
tmpdir
=
/tmp
log_output
=
/dev/kmsg
set
-o
pipefail
# The return value of a pipeline is the status of
# the last command to exit with a non-zero status,
# or zero if no command exited with a non-zero status
# Needed for return value ($?) of xxx in "xxx | tee yyy"
rm
-f
"
$tmpdir
"
/dot-config_source
...
...
@@ -16,17 +23,17 @@ if [ -f $dotconfig ]; then
# source dot-config
.
$dotconfig
ret_source
=
$?
/wr/bin/wrs_checkcfg
$dotconfig
/wr/etc/Kconfig
/wr/bin/wrs_checkcfg
$dotconfig
/wr/etc/Kconfig
2>&1|
tee
$log_output
ret_check
=
$?
if
[
$ret_source
!=
0
]
||
[
$ret_check
!=
0
]
;
then
# errors in local dot-config
echo
"check_error"
>
"
$tmpdir
"
/dot-config_status
echo
"Errors found in local dot-config!!!"
>
& 2
echo
"Errors found in local dot-config!!!"
|
tee
$log_output
>
& 2
else
echo
"config_ok"
>
"
$tmpdir
"
/dot-config_status
fi
else
echo
"No /wr/etc/dot-config to use"
>
& 2
echo
"No /wr/etc/dot-config to use"
|
tee
$log_output
>
& 2
echo
"no_config"
>
"
$tmpdir
"
/dot-config_source
echo
"config_error"
>
"
$tmpdir
"
/dot-config_status
fi
...
...
@@ -67,10 +74,10 @@ if [ "$CONFIG_DOTCONF_SOURCE_REMOTE" = "y" ] || [ "$CONFIG_DOTCONF_SOURCE_TRY_DH
if
[
-f
"
$tmpdir
"
/dot-config_source_url
]
;
then
# replace CONFIG_DOTCONF_URL with one gotten from dhcp
CONFIG_DOTCONF_URL
=
`
cat
"
$tmpdir
"
/dot-config_source_url
`
echo
"Got dot-config's URL ("
$CONFIG_DOTCONF_URL
") via DHCP"
>
& 2
echo
"Got dot-config's URL ("
$CONFIG_DOTCONF_URL
") via DHCP"
|
tee
$log_output
>
& 2
else
echo
"dhcp_error"
>
"
$tmpdir
"
/dot-config_status
echo
"Unable to get dot-config's URL via DHCP, using old dot-config"
>
& 2
echo
"Unable to get dot-config's URL via DHCP, using old dot-config"
|
tee
$log_output
>
& 2
# apply old dot-config
/wr/bin/apply_dot-config
exit
...
...
@@ -105,33 +112,33 @@ if [ "$CONFIG_DOTCONF_SOURCE_REMOTE" = "y" ] || [ "$CONFIG_DOTCONF_SOURCE_TRY_DH
tftp
-g
-r
"
$filename
"
-l
$tmpconfig
$host
;;
*
)
echo
"Invalid URL for dot-config:
\"
$URL
\"
"
>
& 2
echo
"Invalid URL for dot-config:
\"
$URL
\"
"
|
tee
$log_output
>
& 2
;;
esac
if
[
-f
$tmpconfig
]
;
then
# If it exists, it is not empty or too small and the checker is happy
# then try to source it in another shell to verify syntax
if
[
$(
cat
$tmpconfig
|
wc
-c
)
-gt
200
]
&&
/wr/bin/wrs_checkcfg
$tmpconfig
/wr/etc/Kconfig
&&
/wr/bin/wrs_checkcfg
$tmpconfig
/wr/etc/Kconfig
2>&1|
tee
$log_output
&&
/bin/sh
-c
".
$tmpconfig
"
;
then
echo
"Using newly-downloaded dot-config from
$URL
"
>
& 2
echo
"Using newly-downloaded dot-config from
$URL
"
|
tee
$log_output
>
& 2
# copy it in place to use the new file (unless it is identical)
cmp
-s
$tmpconfig
$dotconfig
||
cp
$tmpconfig
$dotconfig
# info for SNMP that downloading was successful and checker is happy
echo
"config_ok"
>
"
$tmpdir
"
/dot-config_status
else
echo
"check_error"
>
"
$tmpdir
"
/dot-config_status
echo
"Errors found in downloaded dot-config
\"
$URL
\"
, using old"
>
& 2
echo
"Errors found in downloaded dot-config
\"
$URL
\"
, using old"
|
tee
$log_output
>
& 2
fi
else
echo
"download_error"
>
"
$tmpdir
"
/dot-config_status
echo
"Download error for dot-config
\"
$URL
\"
, using old"
>
& 2
echo
"Download error for dot-config
\"
$URL
\"
, using old"
|
tee
$log_output
>
& 2
fi
elif
[
"
$CONFIG_DOTCONF_SOURCE_LOCAL
"
=
"y"
]
;
then
echo
"local"
>
"
$tmpdir
"
/dot-config_source
echo
"Using local dot-config"
>
& 2
echo
"Using local dot-config"
|
tee
$log_output
>
& 2
else
echo
"Unknown dot-config source. Using local dot-config"
>
& 2
echo
"Unknown dot-config source. Using local dot-config"
|
tee
$log_output
>
& 2
fi
# Finally, apply what we have, be it old or new
...
...
userspace/rootfs_override/etc/init.d/hwinfo
View file @
8ca5bb52
...
...
@@ -13,6 +13,7 @@ if [ -n "$WRS_VERBOSE" ]; then
set
-x
fi
log_output
=
/dev/kmsg
# This kernel has no hwinfo partition (strange...)
if
!
grep
-q
hwinfo /proc/mtd
;
then
...
...
@@ -23,7 +24,7 @@ fi
if
!
[
-f
/wr/bin/sdb-read
]
;
then
# If for some reason sdb-read is not available, don't touch hwinfo
echo
"
/wr/bin/sdb-read not available!"
echo
"
Error: /wr/bin/sdb-read not available!"
|
tee
$log_output
# save script result for snmp
echo
"hwinfo_error"
>
/tmp/hwinfo_read_status
exit
0
;
...
...
@@ -41,6 +42,7 @@ echo "Creating SDB filesystem in /dev/mtd5"
# So, we must create an sdb file, we need the template
cp
/wr/etc/sdb-for-dataflash.bin /tmp
if
[
$?
-ne
0
]
;
then
echo
"Error: /wr/etc/sdb-for-dataflash.bin not found!"
|
tee
$log_output
echo
"hwinfo_error"
>
/tmp/hwinfo_read_status
exit
1
fi
...
...
@@ -74,5 +76,5 @@ echo "hwinfo_ok" > /tmp/hwinfo_read_status
# reboot if hw info was updated
# Please note that reboot will take pleace after switch finishes booting
echo
-e
"
\n\n
Ordering reboot after hwinfo update!!!
\n\n
"
echo
-e
"
\n\n
Ordering reboot after hwinfo update!!!
\n\n
"
|
tee
$log_output
reboot
userspace/rootfs_override/etc/init.d/network
View file @
8ca5bb52
...
...
@@ -5,12 +5,13 @@
dotconfig
=
/wr/etc/dot-config
int_file
=
/etc/network/interfaces
log_output
=
/dev/kmsg
# no matter what we do keep lo up
ifup lo &> /dev/null
if
grep
-q
'/ nfs'
/proc/mounts
;
then
echo
"Running via NFS: leaving eth0 config alone"
echo
"Running via NFS: leaving eth0 config alone"
|
tee
$log_output
exit
0
fi
...
...
@@ -60,21 +61,21 @@ fi
if
[
"
$CONFIG_HOSTNAME_STATIC
"
=
"y"
]
;
then
if
[
-z
"
$CONFIG_HOSTNAME_STRING
"
]
;
then
echo
"empty CONFIG_HOSTNAME_STRING! use wrs"
echo
"empty CONFIG_HOSTNAME_STRING! use wrs"
|
tee
$log_output
CONFIG_HOSTNAME_STRING
=
"wrs"
fi
/bin/hostname
"
$CONFIG_HOSTNAME_STRING
"
echo
"
$CONFIG_HOSTNAME_STRING
"
>
/etc/hostname
echo
"
$CONFIG_HOSTNAME_STRING
"
|
tee
$log_output
>
/etc/hostname
elif
[
"
$CONFIG_HOSTNAME_DHCP
"
=
"y"
]
;
then
DHCP_OPT_EXTRA
=
"-O hostname -s /wr/bin/dhcp_extra_opt.sh"
fi
if
[
"
$CONFIG_ETH0_DHCP_ONCE
"
=
"y"
]
;
then
echo
"Try DHCP to get IP"
echo
"Try DHCP to get IP"
|
tee
$log_output
# try dhcp, if fail use static IP
udhcpc
-i
eth0
-n
$DHCP_OPT_EXTRA
udhcpc
-i
eth0
-n
$DHCP_OPT_EXTRA
|
tee
$log_output
if
[
$?
-ne
0
]
;
then
echo
"Failed to obtain IP address via DHCP, set static IP"
echo
"Failed to obtain IP address via DHCP, set static IP"
|
tee
$log_output
CONFIG_ETH0_STATIC
=
"y"
else
exit
...
...
@@ -83,12 +84,14 @@ fi
if
[
"
$CONFIG_ETH0_STATIC
"
=
"y"
]
;
then
# ifup to use static parameters from /etc/netwrok/interfaces
echo
"Using static IP"
echo
"Using static IP"
|
tee
$log_output
ifup eth0
exit
fi
# Try to get IP via dhcp if failed run dhcp client forever in background.
# If no information how to get IP address is available use this option.
echo
"Using DHCP to get IP"
udhcpc
-b
-i
eth0
$DHCP_OPT_EXTRA
echo
"Using DHCP to get IP"
|
tee
$log_output
# redirect output from udhcpc into syslog and output about the first lease to
# the kernel log (syslog is not started at this point)
udhcpc
-S
-b
-i
eth0
$DHCP_OPT_EXTRA
|
tee
$log_output
userspace/rootfs_override/etc/init.d/nslcd.sh
View file @
8ca5bb52
...
...
@@ -4,6 +4,7 @@
#
MONIT
=
/usr/bin/monit
dotconfig
=
/wr/etc/dot-config
log_output
=
/dev/kmsg
start_counter
()
{
# increase boot counter
...
...
@@ -23,11 +24,11 @@ start() {
if
[
-f
"
$dotconfig
"
]
;
then
.
"
$dotconfig
"
else
echo
"
$0
unable to source dot-config (
$dotconfig
)!"
echo
"
$0
unable to source dot-config (
$dotconfig
)!"
|
tee
$log_output
fi
if
[
"
$CONFIG_LDAP_ENABLE
"
!=
"y"
]
;
then
echo
"LDAP not enabled in dot-config"
echo
"LDAP not enabled in dot-config"
|
tee
$log_output
# Unmonitor web server (nslcd), ignore all printouts
# from monit.
# Run in background since monit may wait for a timeout.
...
...
@@ -36,7 +37,7 @@ start() {
fi
if
[
-z
"
$CONFIG_LDAP_SERVER
"
]
;
then
echo
"Failed! LDAP server not defined"
echo
"Failed! LDAP server not defined"
|
tee
$log_output
exit
0
fi
# fill LDAP server address
...
...
@@ -44,7 +45,7 @@ start() {
sed
-i
"s,^uri CONFIG_LDAP_SERVER_ADDRESS,uri
$CONFIG_LDAP_SERVER
,g"
/etc/nslcd.conf
if
[
-z
"
$CONFIG_LDAP_SEARCH_BASE
"
]
;
then
echo
"Failed! LDAP search base not defined"
echo
"Failed! LDAP search base not defined"
|
tee
$log_output
exit
0
fi
# fill LDAP search base
...
...
@@ -55,12 +56,12 @@ start() {
sed
-i
"s/CONFIG_LDAP_FILTER//g"
/etc/nslcd.conf
elif
[
"
$CONFIG_LDAP_FILTER_EGROUP
"
=
"y"
]
;
then
if
[
-z
"
$CONFIG_LDAP_FILTER_EGROUP_STR
"
]
;
then
echo
-n
"Warning: CONFIG_LDAP_FILTER_EGROUP_STR empty! "
echo
-n
"Warning: CONFIG_LDAP_FILTER_EGROUP_STR empty! "
|
tee
$log_output
fi
sed
-i
"s/CONFIG_LDAP_FILTER/(memberOf=CN=
$CONFIG_LDAP_FILTER_EGROUP_STR
,OU=e-groups,OU=Workgroups,
$CONFIG_LDAP_SEARCH_BASE
)/g"
/etc/nslcd.conf
elif
[
"
$CONFIG_LDAP_FILTER_CUSTOM
"
=
"y"
]
;
then
if
[
-z
"
$CONFIG_LDAP_FILTER_CUSTOM_STR
"
]
;
then
echo
-n
"Warning: CONFIG_LDAP_FILTER_CUSTOM_STR empty! "
echo
-n
"Warning: CONFIG_LDAP_FILTER_CUSTOM_STR empty! "
|
tee
$log_output
fi
sed
-i
"s/CONFIG_LDAP_FILTER/
$CONFIG_LDAP_FILTER_CUSTOM_STR
/g"
/etc/nslcd.conf
fi
...
...
@@ -74,7 +75,7 @@ start() {
cp
-a
/usr/etc/pam.d/sshd /etc/pam.d/sshd
if
[
"
$CONFIG_AUTH_KRB5
"
=
"y"
]
;
then
if
[
-z
"
$CONFIG_AUTH_KRB5_SERVER
"
]
;
then
echo
"Failed! CONFIG_AUTH_KRB5_SERVER empty!"
echo
"Failed! CONFIG_AUTH_KRB5_SERVER empty!"
|
tee
$log_output
exit
0
fi
...
...
userspace/rootfs_override/wr/bin/apply_dot-config
View file @
8ca5bb52
...
...
@@ -9,6 +9,8 @@
# When called with "local_config" parameter, files with information about
# dotconfig source are removed (used by SNMP)
log_output
=
/dev/kmsg
# We create a temporary file in /tmp, store all files in ramdisk
tmpdir
=
/tmp
...
...
@@ -37,7 +39,7 @@ if [ "$1" == "local_config" ]; then
echo
"config_ok"
>
"
$tmpdir
"
/dot-config_status
fi
else
echo
"No /wr/etc/dot-config to use"
>
& 2
echo
"No /wr/etc/dot-config to use"
|
tee
$log_output
>
& 2
echo
"no_config"
>
"
$tmpdir
"
/dot-config_source
echo
"config_error"
>
"
$tmpdir
"
/dot-config_status
configured
=
false
...
...
@@ -133,7 +135,7 @@ elif [ "$CONFIG_PTP_REMOTE_CONF" = "y" ]; then
tftp
-g
-r
"
$filename
"
-l
$tmpconfig
$host
;;
*
)
echo
"Invalid URL for ppsi.conf:
\"
$URL
\"
"
>
& 2
echo
"Invalid URL for ppsi.conf:
\"
$URL
\"
"
|
tee
$log_output
>
& 2
;;
esac
if
[
-f
$tmpconfig
]
;
then
...
...
@@ -142,5 +144,5 @@ elif [ "$CONFIG_PTP_REMOTE_CONF" = "y" ]; then
fi
else
# no valid PTP option keep ppsi.conf with old postfix
echo
"No valid PTP option in dot-config!"
>
& 2
echo
"No valid PTP option in dot-config!"
|
tee
$log_output
>
& 2
fi
userspace/rootfs_override/wr/bin/assembly_ppsi_conf.sh
View file @
8ca5bb52
...
...
@@ -13,6 +13,7 @@
PRE_FILE
=
"/wr/etc/ppsi-pre.conf"
OUTPUT_FILE
=
"/etc/ppsi.conf"
DOTCONFIG_FILE
=
"/wr/etc/dot-config"
log_output
=
/dev/kmsg
unset
JSON_FORMAT
#decode script parameters
...
...
@@ -54,10 +55,10 @@ function get_fiber_delay_coeff() {
IFS
=
'='
read
-a
fpa
<<<
"
$fiber_param
"
dc
=
${
fpa
[1]
}
else
echo
"
$script_name
: Unknown fiber=
\"
$fb
\"
in CONFIG_PORT"
$i_port
"_FIBER"
echo
"
$script_name
: Unknown fiber=
\"
$fb
\"
in CONFIG_PORT"
$i_port
"_FIBER"
|
tee
$log_output
fi
else
echo
"
$script_name
: Invalid parameter fiber=
\"
$fb
\"
in CONFIG_PORT"
$i_port
"_FIBER"
echo
"
$script_name
: Invalid parameter fiber=
\"
$fb
\"
in CONFIG_PORT"
$i_port
"_FIBER"
|
tee
$log_output
fi
fi
echo
"
$dc
"
...
...
@@ -324,7 +325,7 @@ function set_instance_profile() {
eval
${
lv
}
=
"ptp"
set_profile_for_PTP
$inst
elif
[
-n
"
$p
"
]
;
then
echo
"
$script_name
: Invalid parameter profile=
\"
$p
\"
in
${
inst
}
"
echo
"
$script_name
: Invalid parameter profile=
\"
$p
\"
in
${
inst
}
"
|
tee
$log_output
eval
${
lv
}
=
"ha"
else
# default
...
...
@@ -586,7 +587,7 @@ for i_port in {01..18}; do # scan all the physical ports
&&
[
"
$ppsi_vlans
"
-le
4094
]
&> /dev/null
;
then
v
=
"
$inst_vn
[vlan]"
;
eval
${
v
}
=
"
$ppsi_vlans
"
else
echo
"
$script_name
: Wrong value
\"
$ppsi_vlans
\"
in CONFIG_VLANS_PORT"
$i_port
"_VID"
echo
"
$script_name
: Wrong value
\"
$ppsi_vlans
\"
in CONFIG_VLANS_PORT"
$i_port
"_VID"
|
tee
$log_output
continue
;
fi
fi
...
...
userspace/rootfs_override/wr/bin/dhcp_extra_opt.sh
View file @
8ca5bb52
...
...
@@ -7,6 +7,10 @@
# udhcpc should get hostname the from DHCP server.
#
# check whether we got hostname from DHCP server
log_output
=
/dev/kmsg
exec
1>
$log_output
if
[
-n
"
$hostname
"
]
;
then
/bin/hostname
"
$hostname
"
echo
"
$hostname
"
>
/etc/hostname
...
...
userspace/rootfs_override/wr/etc/rsyslog.conf.in
View file @
8ca5bb52
...
...
@@ -8,6 +8,8 @@
#$ModLoad immark # provides --MARK-- message capability
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imklog # kernel logging (formerly provided by rklogd)
$KLogPermitNonKernelFacility on # read messages with non kernel facility from /proc/kmsg via imklog module
$PreserveFQDN on
...
...
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