-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-reLuminate.sh
84 lines (68 loc) · 2 KB
/
install-reLuminate.sh
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
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
# Created with inspiration from https://github.com/rM-self-serve/webinterface-onboot/blob/master/install-webint-ob.sh
# --- Values replaced in github actions ---
version='VERSION'
# -----------------------------------------
installfile='./install-reLuminate.sh'
pkgname='reLuminate'
servicefile="/lib/systemd/system/${pkgname}.service"
main() {
case "$@" in
'install' | '')
install
;;
'remove')
remove
;;
*)
echo 'input not recognized'
cli_info
exit 0
;;
esac
}
cli_info() {
echo "${pkgname} installer ${version}"
echo -e "${CYAN}COMMANDS:${NC}"
echo ' install'
echo ' remove'
echo ''
}
install() {
echo "Install ${pkgname} ${version}"
# Make file system writeable
echo "Remounting file system"
umount -l /etc
mount -o remount,rw /
# Create reLuminate systemd service file
echo "Creating systemd service file"
cat > $servicefile <<EOF
[Unit]
Description=Enable linear_mapping for reading light
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c 'echo yes > /sys/class/backlight/rm_frontlight/linear_mapping'
ExecStartPost=/bin/sh -c 'cat /sys/class/backlight/rm_frontlight/max_brightness > /sys/class/backlight/rm_frontlight/brightness'
ExecStop=/bin/sh -c 'echo no > /sys/class/backlight/rm_frontlight/linear_mapping'
ExecStopPost=/bin/sh -c 'echo 260 > /sys/class/backlight/rm_frontlight/brightness'
[Install]
WantedBy=multi-user.target
EOF
# Start service
echo "Enabling $pkgname"
systemctl daemon-reload
systemctl enable ${pkgname} --now
echo "Finished installing $pkgname"
}
remove() {
echo "Remove ${pkgname}"
echo "Disabling $pkgname"
systemctl disable "$pkgname" --now
# Remove service file and install file
[[ -f $servicefile ]] && rm $servicefile
[[ -f $installfile ]] && rm $installfile
echo "Finished removing ${pkgname}"
}
main "$@"