/
mod_show_name
executable file
·153 lines (153 loc) · 4.47 KB
/
mod_show_name
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# MODFS_MODSCRIPT
# SPDX-License-Identifier: GPL-2.0-or-later
# SUPPORTS precheck postcheck install language(en,de)
# NAME show device name instead of type on GUI
# DESCRIPTION en
# initial display of device name as HTML title and in the headline
# DESCRIPTION de
# Start mit der Anzeige des Gerätenamens anstelle des Typs in der Kopfzeile und im HTML-Titel;
# dann nützlich, wenn man mehrere Boxen desselben Typs verwaltet und sofort sehen will, auf
# welcher man gerade ist
# EOH
#
# process parameters
#
language=$1
rootdir=$2
mode=$3
step=$4
[ ${#4} -eq 0 ] && exit 59 # invalid call
#
# variables
#
rc=0
check_filename="$rootdir/usr/www/$TARGET_BRANDING/content.lua"
check_trigger="<title><?lua box.html(g_fb_name) ?></title>"
#
# apply
#
patch_file()
{
local home=$(pwd)
cd $rootdir
$home/bin/$HWRevision/busybox patch -p0 2>/dev/null 1>/dev/null <<EOT
--- usr/www/$TARGET_BRANDING/content.lua
+++ usr/www/$TARGET_BRANDING/content.lua
@@ -87,5 +87,5 @@
<link rel="stylesheet" type="text/css" href="/css/box.css">
<link rel="stylesheet" type="text/css" href="/css/rd/main.css">
-<title><?lua box.html(g_fb_type) ?></title>
+<title><?lua box.html(g_fb_name) ?></title>
</head>
<body>
--- usr/www/$TARGET_BRANDING/content.lua
+++ usr/www/$TARGET_BRANDING/content.lua
@@ -56,7 +56,7 @@
<link rel="stylesheet" type="text/css" href="/css/default/chartist.css">
<link rel="stylesheet" type="text/css" href="/css/default/chartistplugins.css">
<link rel="stylesheet" type="text/css" href="/css/rd/main.css">
-<title><?lua box.html(g_fb_type) ?></title>
+<title><?lua box.html(g_fb_name) ?></title>
</head>
<body class="hideMenu">
<nav id="menuBox" class="hidden" aria-live="off">
--- usr/www/$TARGET_BRANDING/content.lua
+++ usr/www/$TARGET_BRANDING/content.lua
@@ -55,7 +55,7 @@
<head>
<?include "templates/head_tag_content.lua" ?>
<link rel="stylesheet" type="text/css" href="/css/rd/main.css">
-<title><?lua box.html(g_fb_type) ?></title>
+<title><?lua box.html(g_fb_name) ?></title>
</head>
<body class="hideMenu">
<nav id="menuBox" class="hidden" aria-live="off">
--- usr/www/$TARGET_BRANDING/content.lua
+++ usr/www/$TARGET_BRANDING/content.lua
@@ -78,7 +78,7 @@
<?include "templates/head_tag_content.lua" ?>
<link rel="stylesheet" type="text/css" href="/css/rd/main.css">
<link rel="stylesheet" type="text/css" href="/css/box.css">
-<title><?lua box.html(g_fb_type) ?></title>
+<title><?lua box.html(g_fb_name) ?></title>
</head>
<body class="hideMenu">
<nav id="menuBox" class="hidden" aria-live="off">
--- usr/www/$TARGET_BRANDING/content.lua
+++ usr/www/$TARGET_BRANDING/content.lua
@@ -85,8 +85,8 @@
<header id="blueBarBox" class="hidden">
<div id="blueBarLogo" class="blueBarLogo"></div>
<div id="blueBarRightBox" class="blueBarRightBox">
-<div id="blueBarTitel" class="blue_bar_title">
-<?lua box.html(g_fb_type) ?>
+<div id="blueBarTitel" class="blue_bar_title userName">
+<?lua box.html(g_fb_name) ?>
</div>
<div id="blueBarUserMenuIcon" class="blueBarUser <?lua if gUsername and "" ~= gUsername then box.html('showName') end ?>" role="button" aria-haspopup="true" aria-label="{?354:949?}" aria-expanded="false" aria-controls="userMenuBox">
<?lua if gUsername then box.html(gUsername) end ?>
--- usr/www/$TARGET_BRANDING/content.lua
+++ usr/www/$TARGET_BRANDING/content.lua
@@ -93,9 +93,9 @@
<header id="blueBarBox" class="hidden">
<div id="blueBarLogo" class="blueBarLogo"></div>
<div id="blueBarRightBox" class="blueBarRightBox">
<div id="blueBarTitel" class="blue_bar_title focus-title-semibold">
-<?lua box.html(g_fb_type) ?>
+<?lua box.html(g_fb_name) ?>
</div>
<div id="blueBarUserMenuIcon" class="blueBarUser" role="button" aria-haspopup="true" aria-label="{?354:568?}" aria-expanded="false" aria-controls="userMenuBox"></div>
</div>
</header>
EOT
cd $home
}
#
# execute steps
#
case $step in
precheck)
grep -q "$check_trigger" $check_filename 2>/dev/null 1>&2
rc=$?
if [ $rc -eq 0 ]; then
case "$language" in
de)
echo "Die Modifikation wurde bereits angewendet."
;;
*)
echo "The modification is already present."
;;
esac
rc=1
else
rc=0
fi
;;
postcheck)
grep -q "$check_trigger" $check_filename 2>/dev/null 1>&2
rc=$?
if [ $rc -eq 1 ]; then
case "$language" in
de)
echo "Die Modifikation war nicht erfolgreich."
;;
*)
echo "The menu file seems to be unmodified."
;;
esac
rc=1
else
rc=0
fi
;;
install)
for TARGET_BRANDING in $TARGET_BRANDINGS; do
patch_file
done
rc=0
;;
*)
rc=59
;;
esac
exit $rc