Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

falter-common: add /etc/profile.d/dynbanner.sh #61

Merged
merged 1 commit into from
Oct 29, 2020

Conversation

Akira25
Copy link
Member

@Akira25 Akira25 commented Oct 25, 2020

This package embeds regularily dynamic system information (i.e. system load,
uptime, amount of clients) into the banner. To protect the flash (limited amounts of writing cycles),
it uses tmpfs to store the new banner.

@PolynomialDivision
Copy link
Contributor

root@DumbAP1:~# opkg install falter-berlin-dynamic-banner_0.1.0-1_all.ipk 
Installing falter-berlin-dynamic-banner (0.1.0-1) to root...
Configuring falter-berlin-dynamic-banner.
crontab: can't open 'root': No such file or directory

@PolynomialDivision
Copy link
Contributor

PolynomialDivision commented Oct 25, 2020

$ ssh root@10.0.0.2


BusyBox v1.31.1 () built-in shell (ash)

root@DumbAP1:~# 

@PolynomialDivision
Copy link
Contributor

PolynomialDivision commented Oct 25, 2020

Just installed this on a normal OpenWrt-Snapshot Router? Is that wrong via opkg?

@Akira25
Copy link
Member Author

Akira25 commented Oct 25, 2020

Just installed this on a normal OpenWrt-Snapshot Router? Is that wrong via opkg?

No. That should work perfectly fine. Did you take the current code? I did some force-pushes within the last half our.

@PolynomialDivision
Copy link
Contributor

root@DumbAP1:~# /usr/bin/refresh_banner.sh
uci: Entry not found
wc: /tmp/dhcp.leases: No such file or directory

@PolynomialDivision
Copy link
Contributor

After manualling executing the script i tlooks awesome! :D

$ ssh root@10.0.0.2


BusyBox v1.31.1 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r14740-0b31713c85
 -----------------------------------------------------
 Host.............................: DumbAP1.olsr
 IP-Address.......................: 
 Uptime...........................: 1 day
 Free flash.......................: 2.8M
 Average load (1m, 5m, 15m).......: 0.00, 0.00, 0.00		
 DHCP-Clients.....................: 0

 

@PolynomialDivision
Copy link
Contributor

Ich glaube der filename ist nicht so rictig: packages/falter-berlin-dynamic-banner/files/uci-defaults.sh
Ich bin der meinung, dass muss unter den oderner files/uci-defaults/add-banner.sh?

Copy link
Collaborator

@pmelange pmelange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having a dynamic banner is simply cool. But here are a few changes which may make this addition a bit better.

@pmelange
Copy link
Collaborator

pmelange commented Oct 26, 2020

I just did a test. Whatever I execute in /etc/profile.d/dynbanner.sh is ran after the banner is printed. Here is my suggestion.

  • Don't delete the orignal banner
  • modify your script to only be in /etc/profile.d/dynbanner.sh and print directly from there.
  • no cronjob needed

I think it would be a lot cleaner. It may not need to be it's own package anymore either. Maybe it would make more sense to go in falter-common.

@Akira25
Copy link
Member Author

Akira25 commented Oct 26, 2020

@pmelange Your suggestion is really neat indeed. At all events, we need to adjust /etc/profile. What would be the most elegant way to do this? Currently I try to get hedy-makefile run with falter. Than we could do a patch on this file. Or should we maybe hack that with an uci-defaults-script too?

@Akira25
Copy link
Member Author

Akira25 commented Oct 26, 2020

I just did a test. Whatever I execute in /etc/profile.d/dynbanner.sh is ran after the banner is printed. Here is my suggestion.

* Don't delete the orignal banner

* modify your script to only be in /etc/profile.d/dynbanner.sh and print directly from there.

* no cronjob needed

I think it would be a lot cleaner. It may not need to be it's own package anymore either. Maybe it would make more sense to go in falter-common.

Ah, okay, now I get your point. We don't need to patch /etc/profile. The way you suggested it, it still gets printed like it was one banner:

  _____        _  __             _
 |  ___|      (_)/ _|           | |
 | |_ _ __ ___ _| |_ _   _ _ __ | | __
 |  _| '__/ _ \ |  _| | | | '_ \| |/ /
 | | | | |  __/ | | | |_| | | | |   <
 \_| |_|  \___|_|_|  \__,_|_| |_|_|\_\

 Firmware Berlin (Hedy 1.0.6 rev v1.0.6)
 Generic - ar71xx/generic
 https://wiki.freifunk.net/Berlin:Firmware
 https://github.com/freifunk-berlin
 -----------------------------------------------------

 If you find bugs please report them at:

   https://github.com/freifunk-berlin/firmware/issues

 For questions write a mail to <berlin@berlin.freifunk.net>
 or check https://berlin.freifunk.net/contact for our weekly meetings.

 Host.............................: fffw-dev.olsr
 IP-Address.......................: 10.31.40.149
 Uptime...........................:  2:05
 Free flash.......................: 10.1M
 Average load (1m, 5m, 15m).......: 0.08, 0.02, 0.00
 DHCP-Clients.....................: 1

 

@Akira25 Akira25 changed the title falter-berlin-dynamic-banner: add Package falter-berlin-dynamic-banner falter-common: add /etc/profile.d/dynbanner.sh Oct 26, 2020
@Akira25 Akira25 requested a review from pmelange October 26, 2020 17:02
@Akira25 Akira25 force-pushed the feature_dynamic-motd branch 2 times, most recently from b8bc128 to 6468a26 Compare October 26, 2020 17:31
@pmelange
Copy link
Collaborator

You are still calling rev.sh.

@Akira25
Copy link
Member Author

Akira25 commented Oct 26, 2020

You are still calling rev.sh.

No that is solved. :)

@pmelange
Copy link
Collaborator

one more small change request. Please use "uci -q get" instead of "uci get"

@pmelange
Copy link
Collaborator

Normally the directory /etc/profile.d does not exist. I don't know if it makes a difference, but you might have to update the Makefile. Could you please try installing this on a fresh system and check that it works?

@Akira25
Copy link
Member Author

Akira25 commented Oct 26, 2020

This gets built now. I can probably test this in one hour or so...

At login time the script dynbanner.sh fetches some dynamic system
information and prints it under the regular banner.
@pmelange
Copy link
Collaborator

FYI. I took a look at the code in /etc/profile and saw the following:

[ -n "$FAILSAFE" ] || {
	for FILE in /etc/profile.d/*.sh; do
		[ -e "$FILE" ] && . "$FILE"
	done
	unset FILE
}

And that is where the suggestion to change everything came from.

@pmelange
Copy link
Collaborator

This gets built now. I can probably test this in one hour or so...

How did the test go?

@Akira25
Copy link
Member Author

Akira25 commented Oct 27, 2020

How did the test go?

The build failed due to a broken dependency on libcap. Probably, this isn't an issue of the change. I try to work around this.

@Akira25
Copy link
Member Author

Akira25 commented Oct 29, 2020

@pmelange I was able to build this. The profile.d/ directory works fine, even on a freshly flashed node without wizard run:

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 19.07.4, r11208-ce6496d796
 -----------------------------------------------------
 Host.............................: gib-mir-einen-namen.olsr
 IP-Address.......................: 
 Uptime...........................: 2 min
 Free flash.......................: 
 Average load (1m, 5m, 15m).......: 1.46, 0.58, 0.22
 DHCP-Clients.....................: 1


=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------

@Akira25
Copy link
Member Author

Akira25 commented Oct 29, 2020

After wizard-run:

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 19.07.4, r11208-ce6496d796
 -----------------------------------------------------
 Host.............................: testnode.olsr
 IP-Address.......................: 172.16.5.1
 Uptime...........................: 1 min
 Free flash.......................: 9.0M
 Average load (1m, 5m, 15m).......: 2.34, 0.75, 0.26
 DHCP-Clients.....................: 1

@pmelange pmelange merged commit 5ba514e into master Oct 29, 2020
@Akira25 Akira25 deleted the feature_dynamic-motd branch November 15, 2020 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants