Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFS Gluon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
firmware
FFS Gluon
Commits
1b40cadc
Unverified
Commit
1b40cadc
authored
1 year ago
by
Maciej Krüger
Browse files
Options
Downloads
Patches
Plain Diff
gluon-core: move all info into module
parent
2c2e57ec
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
package/gluon-core/luasrc/usr/bin/gluon-info
+5
-31
5 additions, 31 deletions
package/gluon-core/luasrc/usr/bin/gluon-info
package/gluon-core/luasrc/usr/lib/lua/gluon/info.lua
+50
-0
50 additions, 0 deletions
package/gluon-core/luasrc/usr/lib/lua/gluon/info.lua
with
55 additions
and
31 deletions
package/gluon-core/luasrc/usr/bin/gluon-info
+
5
−
31
View file @
1b40cadc
#!/usr/bin/lua
local
uci
=
require
(
'simple-uci'
).
cursor
()
local
pretty_hostname
=
require
'pretty_hostname'
local
info
=
require
'gluon.info'
local
site
=
require
'gluon.site'
local
sysconfig
=
require
'gluon.sysconfig'
local
platform
=
require
'gluon.platform'
local
util
=
require
'gluon.util'
local
has_vpn
,
vpn
=
pcall
(
require
,
'gluon.mesh-vpn'
)
local
pubkey
if
has_vpn
and
vpn
.
enabled
()
then
local
_
,
active_vpn
=
vpn
.
get_active_provider
()
if
active_vpn
~=
nil
then
pubkey
=
active_vpn
.
public_key
()
end
end
local
values
=
{
{
'Hostname'
,
pretty_hostname
.
get
(
uci
)
},
{
'MAC address'
,
sysconfig
.
primary_mac
},
{
'Hardware model'
,
platform
.
get_model
()
},
{
'Gluon version / Site version'
,
util
.
trim
(
util
.
readfile
(
'/lib/gluon/gluon-version'
))
..
' / '
..
util
.
trim
(
util
.
readfile
(
'/lib/gluon/site-version'
))
},
{
'Firmware release'
,
util
.
trim
(
util
.
readfile
(
'/lib/gluon/release'
))
},
{
'Site'
,
site
.
site_name
()
},
{
'Domain'
,
uci
:
get
(
'gluon'
,
'core'
,
'domain'
)
or
'n/a'
},
{
'Public VPN key'
,
pubkey
or
'n/a'
},
}
local
values
=
info
.
get_info_pretty
(
function
(
str
)
return
str
end
)
local
padTo
=
24
for
_
,
info
in
ipairs
(
values
)
do
local
labelLen
=
string.len
(
info
[
1
])
+
1
for
_
,
value
in
ipairs
(
values
)
do
local
labelLen
=
string.len
(
value
[
1
])
+
1
print
(
info
[
1
]
..
':'
..
string.rep
(
' '
,
padTo
-
labelLen
),
info
[
2
])
print
(
value
[
1
]
..
':'
..
string.rep
(
' '
,
padTo
-
labelLen
),
value
[
2
])
end
This diff is collapsed.
Click to expand it.
package/gluon-core/luasrc/usr/lib/lua/gluon/info.lua
0 → 100644
+
50
−
0
View file @
1b40cadc
local
uci
=
require
(
'simple-uci'
).
cursor
()
local
pretty_hostname
=
require
'pretty_hostname'
local
site
=
require
'gluon.site'
local
sysconfig
=
require
'gluon.sysconfig'
local
platform
=
require
'gluon.platform'
local
util
=
require
'gluon.util'
local
has_vpn
,
vpn
=
pcall
(
require
,
'gluon.mesh-vpn'
)
local
pubkey
if
has_vpn
and
vpn
.
enabled
()
then
local
_
,
active_vpn
=
vpn
.
get_active_provider
()
if
active_vpn
~=
nil
then
pubkey
=
active_vpn
.
public_key
()
end
end
local
M
=
{}
function
M
.
get_info
()
return
{
hostname
=
pretty_hostname
.
get
(
uci
),
mac_address
=
sysconfig
.
primary_mac
,
hardware_model
=
platform
.
get_model
(),
gluon_version
=
util
.
trim
(
util
.
readfile
(
'/lib/gluon/gluon-version'
)),
site_version
=
util
.
trim
(
util
.
readfile
(
'/lib/gluon/site-version'
)),
firmware_release
=
util
.
trim
(
util
.
readfile
(
'/lib/gluon/release'
)),
site
=
site
.
site_name
(),
domain
=
uci
:
get
(
'gluon'
,
'core'
,
'domain'
),
public_vpn_key
=
pubkey
,
}
end
function
M
.
get_info_pretty
(
_
)
local
data
=
M
.
get_info
()
return
{
{
_
(
'Hostname'
),
data
.
hostname
},
{
_
(
'MAC address'
),
data
.
mac_address
},
{
_
(
'Hardware model'
),
data
.
hardware_model
},
{
_
(
'Gluon version'
)
..
" / "
..
_
(
'Site version'
),
data
.
gluon_version
..
" / "
..
data
.
site_version
},
{
_
(
'Firmware release'
),
data
.
firmware_release
},
{
_
(
'Site'
),
data
.
site
},
{
_
(
'Domain'
),
data
.
domain
or
'n/a'
},
{
_
(
'Public VPN key'
),
data
.
public_vpn_key
or
'n/a'
},
}
end
return
M
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment