Skip to content

Commit 3c5c067

Browse files
committed
autocols to set stty cols
1 parent 8eaf2f6 commit 3c5c067

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

alpine/aarch64/init

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ mkdir /dev/pts
66
mount -t devpts devpts /dev/pts
77
mount -t tmpfs tmpfs /tmp
88

9-
echo "Configuring networking..."
109
ifconfig eth0 10.0.2.15 netmask 255.255.255.0
1110
route add default gw 10.0.2.2
1211
ifconfig lo 127.0.0.1 netmask 255.0.0.0
1312

14-
echo -e "Boot took $(cut -d' ' -f1 /proc/uptime) seconds."
13+
mount -t 9p -o trans=virtio,version=9p2000.L hostshare /mnt/share
14+
15+
clear
16+
#echo -e "\nBoot took $(cut -d' ' -f1 /proc/uptime) seconds."
1517

1618
exec /sbin/init

alpine/aarch64/usr/sbin/autocols

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
3+
# Save current stty settings
4+
oldstty=$(stty -g)
5+
6+
# Set terminal to raw mode, no echo
7+
stty raw -echo
8+
9+
# Send the escape sequence to request cursor position
10+
printf '\0337\033[r\033[999;999H\033[6n'
11+
12+
# Read the response: ESC [ rows ; cols R
13+
# Read first two bytes (ESC and [)
14+
c1=$(dd bs=1 count=1 2>/dev/null)
15+
c2=$(dd bs=1 count=1 2>/dev/null)
16+
17+
rows=""
18+
cols=""
19+
if [ "$c1$c2" = "$(printf '\033[')" ]; then
20+
# Read rows (until ';')
21+
while :; do
22+
c=$(dd bs=1 count=1 2>/dev/null)
23+
[ "$c" = ";" ] && break
24+
rows="${rows}${c}"
25+
done
26+
# Read cols (until 'R')
27+
while :; do
28+
c=$(dd bs=1 count=1 2>/dev/null)
29+
[ "$c" = "R" ] && break
30+
cols="${cols}${c}"
31+
done
32+
fi
33+
34+
# Restore terminal settings
35+
stty "$oldstty"
36+
37+
# Set terminal cols
38+
[ -n "$cols" ] && stty cols "$cols"
39+
40+
# Optionally print values
41+
echo "Rows: $rows"
42+
echo "Cols: $cols"

alpine/aarch64/usr/sbin/autologin

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/sh
2-
echo -e "\nUptime $(cut -d' ' -f1 /proc/uptime)s\n"
2+
/usr/sbin/autocols
3+
clear
4+
echo -e "Uptime $(cut -d' ' -f1 /proc/uptime)s\n"
35
exec login -f root

0 commit comments

Comments
 (0)