-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfin
More file actions
72 lines (60 loc) · 1.79 KB
/
fin
File metadata and controls
72 lines (60 loc) · 1.79 KB
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
#!/bin/sh
#oxr 2025
# gestion de salida del sistema por tiempo o temperatura
#
# \\r fin [[-+]t [nº]] [[-p]oweroff [-h]ibernate [-s]leep [-r]eboot]
#
# '-t|+t' cuando la temperatura baje o suba hasta nº, sino en nº o 300 segundos
# '-[p|h|s|r]' accion a realizar, sino hibernate
#
[ "$USER" = "root" ] || { su - root -c "exec $0 $*" ; return ;}
PATH=$PATH:~/code
[ $include_ctl ] || . include ; include varize tize # isnum - varize incluye enum y este isnum
fin(){
a="" t="" g="" c="" d="" r="" o="-le"
# a accion - t tiempo - g grados - c texto - d dirtemp - r read - o operador
[ $# -eq 0 ] && { infsh ~/code/fin 3 8 ; return 1 ;} || {
while [ $# -ne 0 ] ; do case $1 in
-t) isnum $2 && { g=$2 ; shift 2 ;} || { g=40 ; shift ;} ;;
+t) isnum $2 && { g=$2 ; o="-ge" ; shift 2 ;} || { g=70 ; shift ;} ;;
-p)a=poweroff ; break ;;
-h)a=hibernate ; break ;;
-s)a=sleep ; break ;;
-r)a=reboot ; break ;;
*) [ ${#t} -ne 0 ] && break || { isnum $1 && { t=$1 ; shift ;} || { infsh ~/code/fin 3 8 ; return 1 ;} } ;;
esac ; done
}
[ ${#a} -ne 0 ] || a=reboot
[ ${#g} -eq 0 ] && {
[ ${#t} -ne 0 ] || t=3
c="En $t segundos"
} || {
varize d echo /sys/devices/platform/coretemp.0/hwmon/hwmon*
d=$d/temp1_input
read r < $d
r=$((r/1000)) ; unset $t
[ $o = "-le" ] && c="baje" || c="suba"
c="Cuando Tªactual($rº) $c a $gº"
}
tize -e -c 75 $t / -c 6 $a / -c 2 [s / -c 2 ] / -c 17 $gº / -c 71 $rº / -c 9 -p ... / "$c $a ..." # Esta seguro[s]"
# read c
# [ "$c" = "s" ] || exit 0
[ ${#g} -ne 0 ] && {
until [ $r $o $g ] ; do
sleep 30
read r < $d
r=$((r/1000))
echo 'M[17G[1;97;41m'$rº'[0m'
done
echo "$a en 3 segundos"'[1;5m' ...'[0m'
sleep 3
echo 'M['$((${#a}+16))G ...'[0m'
} || sleep $t
sync
fm false
#umount -a 2>/dev/null
systemctl start $a.target
return 0
}
[ ${0##*/} != fin ] || fin "$@"
#