Skip to content

Commit 5c1ca32

Browse files
authored
Merge pull request #215 from grml/merge-scripts-core
Merge grml-scripts-core
2 parents 5213eb3 + 77f141a commit 5c1ca32

File tree

9 files changed

+123
-5
lines changed

9 files changed

+123
-5
lines changed

debian/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
files
2+
grml-scripts-core.debhelper.log
3+
grml-scripts-core.substvars
4+
grml-scripts-core

debian/control

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Maintainer: Michael Prokop <[email protected]>
55
Build-Depends:
66
asciidoctor,
77
debhelper-compat (= 12),
8-
Standards-Version: 4.6.2
8+
Standards-Version: 4.7.0
99
Rules-Requires-Root: no
1010
Homepage: https://github.com/grml/grml-etc-core
1111
Vcs-Git: https://github.com/grml/grml-etc-core.git
@@ -21,13 +21,16 @@ Conflicts:
2121
grml-autoconfig (<< 0.5-7),
2222
grml-etc (<< 0.8-11),
2323
grml-scripts (<< 0.8-27),
24+
grml-scripts-core (<< 2.1.5~),
2425
Replaces:
26+
grml-scripts-core (<< 2.1.5~),
2527
vim-common,
28+
Provides:
29+
grml-scripts-core
2630
Depends:
2731
${misc:Depends},
32+
perl-base | perl,
2833
vim | nvi | editor,
29-
Recommends:
30-
grml-scripts-core,
3134
Pre-Depends:
3235
${misc:Pre-Depends},
3336
zsh,
@@ -37,3 +40,5 @@ Description: core etcetera files for the Grml system
3740
meant for use on Grml systems this package can be
3841
used on plain Debian (stable/testing/unstable)
3942
systems as well.
43+
This package also includes cpu-screen and ip-screen,
44+
as they are used by the included screen configuration.

debian/grml-etc-core.links

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/usr/share/man/man1/grml-scripts-core.1.gz /usr/share/man/man1/cpu-screen.1.gz
2+
/usr/share/man/man1/grml-scripts-core.1.gz /usr/share/man/man1/ip-screen.1.gz

debian/grml-etc-core.manpages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
manpages/*.1

debian/install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
etc
2+
usr_bin/* usr/bin/
23
usr_share_grml/* usr/share/grml/

debian/rules

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
%:
55
dh $@
66

7-
87
after_dh_auto_clean:
98
$(MAKE) -C doc clean
109

1110
override_dh_auto_build:
1211
$(MAKE) -C doc all
13-

manpages/grml-scripts-core.1

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.\" Filename: grml-scripts-core.1
2+
.\" Purpose: man page for grml-scripts-core
3+
.\" Authors: grml-team (grml.org), (c) Michael Prokop <[email protected]>
4+
.\" Bug-Reports: see https://grml.org/bugs/
5+
.\" License: This file is licensed under the GPL v2.
6+
.\"###############################################################################
7+
8+
.\"###############################################################
9+
.TH grml\-scripts\-core 1 "grml-scripts-core"
10+
.SH "NAME"
11+
grml\-scripts\-core \- core script collection for the Grml distribution
12+
.\"#######################################################
13+
.SH "SCRIPTS"
14+
15+
.SS cpu-screen
16+
output current / available cpu frequencies
17+
(useful for integration into GNU screen)
18+
.SS ip-screen
19+
print ip address (IPv4 only) of configured network interfaces to stdout
20+
(useful for integration into GNU screen)
21+
22+
.SH "BUGS"
23+
Probably. Please report any bugs you find and report
24+
feedback and suggestions to the Grml team.
25+
See https://grml.org/bugs/ for further information.
26+
Thank you!
27+
28+
.SH "SEE ALSO"
29+
screen(1), grml-scripts(8)
30+
31+
.SH "COPYRIGHT"
32+
This man page is copyright \(co 2004-2024 by the Grml team.
33+
Included scripts are under various copyrights, please see
34+
the sources.
35+
.\"###### END OF FILE ##########################################################
36+
.\" vim:tw=60

usr_bin/cpu-screen

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/perl
2+
# Filename: cpu-screen
3+
# Purpose: output current / available cpu frequence (useful for integration into GNU screen)
4+
# Authors: grml-team (grml.org), (c) Chris Hofstaedtler <[email protected]>
5+
# Bug-Reports: see http://grml.org/bugs/
6+
# License: This file is licensed under the GPL v2.
7+
#******************************************************************************
8+
9+
10+
use strict;
11+
use warnings;
12+
13+
sub read_cpu_freq_file {
14+
my ($file) = @_;
15+
open my $fh, '<', $file or return 0;
16+
my $cpu_freq = <$fh>;
17+
$cpu_freq = int($cpu_freq) / 1000;
18+
close $fh;
19+
return $cpu_freq;
20+
}
21+
22+
sub cpu_cur_frequency() {
23+
return read_cpu_freq_file('/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq');
24+
}
25+
26+
sub cpu_max_frequency() {
27+
return read_cpu_freq_file('/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq');
28+
}
29+
30+
sub count_cpus() {
31+
# assume "1" cpu if we can't count it
32+
open my $fh, '<', "/proc/stat" or return 1;
33+
34+
my $count = 0;
35+
while (my $line = <$fh>) {
36+
$count += 1 if $line =~ /^cpu\d/;
37+
}
38+
close $fh;
39+
return $count;
40+
}
41+
42+
43+
my $cpu_count = count_cpus();
44+
my $cpu_freq = cpu_cur_frequency();
45+
46+
if ($cpu_freq == 0) {
47+
print("$cpu_count\n");
48+
} elsif ($cpu_count == 1) {
49+
my $max_cpu_freq = cpu_max_frequency();
50+
if ($cpu_freq == $max_cpu_freq) {
51+
printf("$cpu_freq\n");
52+
} else {
53+
printf("$cpu_freq / $max_cpu_freq\n");
54+
}
55+
} else {
56+
my $max_cpu_freq = cpu_max_frequency();
57+
if ($cpu_freq == $max_cpu_freq) {
58+
printf("$cpu_count * $cpu_freq\n");
59+
} else {
60+
printf("$cpu_count * $cpu_freq / $max_cpu_freq\n");
61+
}
62+
}

usr_bin/ip-screen

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
# Filename: ip-screen
3+
# Purpose: output ip address (IPv4 only) of configured network interfaces (useful for integration into GNU screen)
4+
# Authors: grml-team (grml.org), (c) Darshaka Pathirana <[email protected]>
5+
# Bug-Reports: see http://grml.org/bugs/
6+
# License: This file is licensed under the GPL v2.
7+
#******************************************************************************
8+
9+
hostname -I | sed -e 's/ [^ ]*:.*$//;s/ / | /g;s/ | $//'

0 commit comments

Comments
 (0)