forked from WinEunuuchs2Unix/eyesome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
203 lines (154 loc) · 5.85 KB
/
install.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/bash
# NAME: install.sh
# PATH: Current directory where files downloaded from github
# DESC: Copy eyesome scripts / command files to target directories
# DATE: September 21, 2018. Modified: June 3, 2020.
# PARM: $1=dev developer mode, publish files
# =rm remove files
# =v verify files (again)
# UPDT: Jun 02 2020 - Default sunrise "7:00 am" and sunset "9:00 pm" files.
# Add option to install 'bc'. Correct typos.
# Jun 03 2020 - Don't automatically copy default sunrise and sunset
# files but leave them in installation directory if user wants to
# manually copy them.
# Jun 13 2020 - Use cp -a to keep same file date and time.
CopyFiles () {
echo
echo Installing eyesome programs...
echo
install -v ./eyesome.sh /usr/local/bin/
install -v ./eyesome-cfg.sh /usr/local/bin/
install -v ./eyesome-src.sh /usr/local/bin/
install -v ./eyesome-sun.sh /usr/local/bin/
install -v ./wake-eyesome.sh /usr/local/bin/
install -v ./eyesome-dbus.sh /usr/local/bin/
# June 3, 2020 intentionally omit /usr/local/bin/.eyesome-sunrise (& set)
# cp -v ./.eyesome-sunrise /usr/local/bin/
# cp -v ./.eyesome-sunset /usr/local/bin/
cp -v ./start-eyesome /etc/cron.d/
install -v ./daily-eyesome-sun /etc/cron.daily/
install -v ./systemd-wake-eyesome /lib/systemd/system-sleep/
install -v ./acpi-lid-eyesome.sh /etc/acpi/
cp -v ./acpi-lid-event-eyesome /etc/acpi/events/
} # CopyFiles
RemoveFiles () {
echo
echo Removing eyesome programs...
echo
rm -v -f /usr/local/bin/eyesome.sh
rm -v -f /usr/local/bin/eyesome-cfg.sh
rm -v -f /usr/local/bin/eyesome-src.sh
rm -v -f /usr/local/bin/eyesome-sun.sh
rm -v -f /usr/local/bin/wake-eyesome.sh
rm -v -f /usr/local/bin/eyesome-dbus.sh
rm -v -f /etc/cron.d/start-eyesome
rm -v -f /etc/cron.daily/daily-eyesome-sun
rm -v -f /lib/systemd/system-sleep/systemd-wake-eyesome
rm -v -f /etc/acpi/acpi-lid-eyesome.sh
rm -v -f /etc/acpi/events/acpi-lid-event-eyesome
echo
echo All eyesome programs have been removed, except data files:
echo
echo /usr/local/bin/.eyesome-cfg
echo /usr/local/bin/.eyesome-sunrise
echo /usr/local/bin/.eyesome-sunset
echo
echo This script you are running 'install.sh' has not been removed.
exit 0
} # RemoveFiles
VerifyFiles () {
md5sum -c eyesome.md5
exit 0
} # VerifyFiles
PublishFiles () {
mkdir -p ~/eyesome
cd ~/eyesome
cp -a -v "$0" . # This script install.sh
cp -a -v /usr/local/bin/eyesome.sh .
cp -a -v /usr/local/bin/eyesome-cfg.sh .
cp -a -v /usr/local/bin/eyesome-src.sh .
cp -a -v /usr/local/bin/eyesome-sun.sh .
cp -a -v /usr/local/bin/wake-eyesome.sh .
cp -a -v /usr/local/bin/eyesome-dbus.sh .
# June 2, 2020 intentionally omit /usr/local/bin/.eyesome-sunrise (& set)
cp -a -v /etc/cron.d/start-eyesome .
cp -a -v /etc/cron.daily/daily-eyesome-sun .
cp -a -v /lib/systemd/system-sleep/systemd-wake-eyesome .
cp -a -v /etc/acpi/acpi-lid-eyesome.sh .
cp -a -v /etc/acpi/events/acpi-lid-event-eyesome .
md5sum \
install.sh \
eyesome.sh \
eyesome-cfg.sh \
eyesome-src.sh \
eyesome-sun.sh \
wake-eyesome.sh \
eyesome-dbus.sh \
.eyesome-sunrise \
.eyesome-sunset \
start-eyesome \
daily-eyesome-sun \
systemd-wake-eyesome \
acpi-lid-eyesome.sh \
acpi-lid-event-eyesome \
> eyesome.md5
echo
echo "~/eyesome/eyesome.md5 has been created."
exit 0
} # PublishFiles
Help () {
echo " \
Eyesome will control up to three monitors including hardware laptop display.
Each day sunrise and sunset times are automatically retrieved for your city.
Configure Daytime and Nighttime brightness and gamma levels for your monitors.
Configure the transition duration after sunrise and before sunset to gradually
adjust brightness and gamma levels so changes are not noticable.
This is the main install/removal/verification program. Your options are:
sudo ./install.sh
sudo ./install.sh v
sudo ./install.sh rm
Use 'v' parameter to verify files were downloaded correctly.
Use 'rm' parameter to remove a previous installation. Data files remain.
In the first instance with no parameter passed, eyesome is installed.
After installation configure eyesome by running 'sudo eyesome-cfg.sh'.
"
exit 0
} # Help
Main () {
[[ "$1" == "-h" ]] || [[ "$1" == "--help" ]] && Help # Exits
if [ $(id -u) != 0 ]; then # root powers needed to call this script
echo >&2 $0 must be called with sudo powers
exit 1
fi
[[ "$1" == "dev" ]] && PublishFiles # exits
[[ "$1" == "v" ]] && VerifyFiles # exits
[[ "$1" == "rm" ]] && RemoveFiles # exits
[[ "$1" != "" ]] && Help # exits
if [[ $(command -v yad) == "" ]]; then
echo " \
'yad' package is required for eyesome but it is not installed.
Do you wish to install it now?
Enter [y/Y], any other key to skip installation: "
read -rsn1 input
echo $input
if [[ $input == y ]] || [[ $input == Y ]] ; then
sudo apt install yad
fi
fi
if [[ $(command -v bc) == "" ]]; then
echo " \
'bc' package is required for eyesome but it is not installed.
Do you wish to install it now?
Enter [y/Y], any other key to skip installation: "
read -rsn1 input
echo $input
if [[ $input == y ]] || [[ $input == Y ]] ; then
sudo apt install bc
fi
fi
CopyFiles
echo
echo Eyesome has been installed. Use 'sudo eyesome-cfg.sh' to configure it.
exit 0
} # Main
Main "$@"