forked from AllskyTeam/allsky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·140 lines (123 loc) · 3.22 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
#!/bin/bash
if [ -z "${ALLSKY_HOME}" ]
then
export ALLSKY_HOME="$(realpath $(dirname "${BASH_ARGV0}"))"
fi
source "${ALLSKY_HOME}/variables.sh"
if [[ $EUID -eq 0 ]]; then
(echo
echo -e "${RED}**********"
echo -e "This script must NOT be run as root, do NOT use 'sudo'."
echo -e "**********${NC}"
echo) 1>&2
exit 1
fi
# The user should be running this in the "allsky" directory. Make sure they are.
INSTALL_DIR="allsky"
DIR=$(basename "$PWD")
if [ "$DIR" != "$INSTALL_DIR" ] ; then
(echo
echo -e "${RED}**********"
echo -e "Please run this script from the '$INSTALL_DIR' directory."
echo -e "**********${NC}"
echo) 1>&2
exit 1
fi
CAM=""
NEEDCAM=0
echo
echo "**********************************************"
echo "*** Welcome to the Allsky Camera installer ***"
echo "**********************************************"
echo
calc_wt_size() {
# NOTE: it's tempting to redirect stderr to /dev/null, so supress error
# output from tput. However in this case, tput detects neither stdout or
# stderr is a tty and so only gives default 80, 24 values
WT_HEIGHT=18
WT_WIDTH=$(tput cols)
if [ -z "$WT_WIDTH" ] || [ "$WT_WIDTH" -lt 60 ]; then
WT_WIDTH=80
fi
if [ "$WT_WIDTH" -gt 178 ]; then
WT_WIDTH=120
fi
WT_MENU_HEIGHT=$(($WT_HEIGHT-7))
}
select_camera() {
NEEDCAM=0
if [ ! -e ${ALLSKY_CONFIG}/config.sh ]; then
NEEDCAM=1
# NOTE: The config.sh file is put in place during the 'make install' step below.
# This flag will be checked after 'make install', and trigger an edit to set the camera value.
else
source ${ALLSKY_CONFIG}/config.sh
if [ -z "${CAMERA}" ]; then
NEEDCAM=1
# NOTE: The config.sh file is present, but the CAMERA variable is empty, thus we need to query it.
else
CAM=$CAMERA
fi
fi
if [ $NEEDCAM -eq 1 ]; then
MYCAM=$(whiptail --title "Allsky Software Installer" --menu "Camera Type" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \
"ZWO" "ZWO camera is used for allsky" \
"RPiHQ" "RPiHQ camera is used for allsky" \
3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
CAM=$MYCAM
else
whiptail --msgbox "Camera selection required. Please re-run './install.sh' and select a camera to continue." 10 60
exit 1
fi
fi
}
set_camera() {
sed -i -e "s/^CAMERA=.*$/CAMERA=\"${CAM}\"/" "$ALLSKY_CONFIG/config.sh"
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
whiptail --msgbox "Camera set to $CAM" 10 60
return 0
else
whiptail --msgbox "Something went wrong setting camera to ${CAM}. Error code ${RETVAL}?" 10 60
return 1
fi
}
ask_reboot() {
if (whiptail --title "Allsky Software Installer" --yesno "The Allsky Software is now installed. You should reboot the Raspberry Pi to finish the installation.\n\n Reboot now?" 10 60 \
3>&1 1>&2 2>&3); then
sudo reboot now
else
exit 3
fi
}
calc_wt_size
select_camera
echo -e "${GREEN}* Dependencies installation\n${NC}"
sudo make deps
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo Installing dependencies failed\!
exit 1
fi
echo
echo -e "${GREEN}* Compile allsky software\n${NC}"
make all
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo Compile failed\!
exit 1
fi
echo
echo -e "${GREEN}* Install allsky software\n${NC}"
sudo make install
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo Install failed\!
exit 1
fi
echo
if [ $NEEDCAM -eq 1 ]; then
set_camera
fi
ask_reboot