Skip to content

Commit 8684130

Browse files
Merge pull request #4557 from AllskyTeam/v2024.12.06_03
V2024.12.06 03
2 parents a7a9d7e + 716597e commit 8684130

89 files changed

Lines changed: 1859 additions & 1303 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci_compile.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ jobs:
2121
- uses: actions/checkout@v2
2222

2323
# Runs a set of commands using the runners shell
24-
- name: make deps
24+
- name: make deps all
2525
run: |
26-
sudo make deps
27-
28-
# Info: depends an step "make deps"
29-
- name: make all
30-
run: |
31-
sudo make all
26+
sudo apt update
27+
sudo make -C src deps
28+
make -C src all

Makefile

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,26 @@
11
platform = $(shell uname -m)
2-
prefix =
3-
4-
sysconfdir = ${prefix}/etc
5-
exec_prefix = /usr
6-
bindir = ${exec_prefix}/bin
7-
libexecdir = ${exec_prefix}/libexec/allsky
8-
sharedir = ${exec_prefix}/share/allsky
92

103
.DEFAULT_GOAL := all
114

125
ROOTCHECK=$(shell id -u)
13-
ifneq ($(ROOTCHECK),0)
14-
ifeq ($(PKGBUILD),1)
15-
ROOTCHECK=0
16-
endif
17-
endif
18-
19-
ifeq ($(PKGBUILD),)
20-
PKGBUILD=0
21-
endif
226

237
%:
24-
@make -C src $@
25-
@make -C config_repo $@
26-
@make -C notificationImages $@
27-
@make -C scripts $@
8+
@echo "Nothing to do for 'all'. Run 'sudo make install' instead."
289

29-
deps:
30-
@make -C src $@
31-
32-
.PHONY : deps
3310

34-
install:
3511
ifneq ($(ROOTCHECK), 0)
36-
@echo This must be run with root permissions.
37-
@echo Please run \'sudo make install\'
12+
install:
13+
@echo "This must be run with root permissions."
14+
@echo "Please run 'sudo make install'."
3815
else
16+
install:
3917
@echo `date +%F\ %R:%S` Starting install...
18+
@echo ""
4019
@make -C src $@
20+
@echo ""
4121
@make -C config_repo $@
42-
@make -C notificationImages $@
43-
@make -C scripts $@
44-
@if [ $(PKGBUILD) -eq 1 ]; then \
45-
[ ! -e $(DESTDIR)$(libexecdir) ] && mkdir -p $(DESTDIR)$(libexecdir) \
46-
install allsky.sh $(DESTDIR)$(libexecdir)/allsky.sh; \
47-
fi
48-
@if [ $(PKGBUILD) -ne 1 ]; then \
49-
echo `date +%F\ %R:%S` Setting directory permissions...; \
50-
[ ! -e tmp ] && mkdir tmp; \
51-
chown -R $(SUDO_USER):$(SUDO_USER) ./ ; \
52-
echo ""; \
53-
echo ""; \
54-
echo `date +%F\ %R:%S` Install complete; \
55-
echo ""; \
56-
echo ""; \
57-
fi
22+
@echo ""
23+
@echo "\n\n`date +%F\ %R:%S` Install complete\n\n"
5824
endif
25+
5926
.PHONY : install

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Allsky Camera ![Release](https://img.shields.io/badge/Version-v2024.12.06_02-green.svg) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MEBU2KN75G2NG&source=url)
1+
# Allsky Camera ![Release](https://img.shields.io/badge/Version-v2024.12.06_03-green.svg) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MEBU2KN75G2NG&source=url)
22

33
This is the source code for the Allsky Camera project described [on Instructables](http://www.instructables.com/id/Wireless-All-Sky-Camera/).
44
 

allsky.sh

Lines changed: 68 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,24 @@
33
[[ -z ${ALLSKY_HOME} ]] && export ALLSKY_HOME="$( realpath "$( dirname "${BASH_ARGV0}" )" )"
44
ME="$( basename "${BASH_ARGV0}" )"
55

6-
# NOT_STARTED_MSG, STOPPED_MSG, ERROR_MSG_PREFIX, and ZWO_VENDOR are globals
7-
86
#shellcheck source-path=.
97
source "${ALLSKY_HOME}/variables.sh" || exit "${EXIT_ERROR_STOP}"
8+
9+
# If Allsky is already running, exit. Let prior copy continue runnning.
10+
if [[ $( pgrep --count "${ME}" ) -gt 1 ]]; then
11+
echo " ***** Allsky already running; see below. Exiting new copy. *****" >&2
12+
# Show other processes. Don't show any newer than 5 seconds so we don't show ourself.
13+
ps -f -p "$( pgrep --older 5 "${ME}" )"
14+
exit "${EXIT_ERROR_STOP}"
15+
fi
16+
1017
#shellcheck source-path=scripts
1118
source "${ALLSKY_SCRIPTS}/functions.sh" || exit "${EXIT_ERROR_STOP}"
1219
#shellcheck source-path=scripts
1320
source "${ALLSKY_SCRIPTS}/installUpgradeFunctions.sh" || exit "${EXIT_ERROR_STOP}"
1421

22+
# NOT_STARTED_MSG, STOPPED_MSG, ERROR_MSG_PREFIX, and ZWO_VENDOR are globals
23+
1524
# Output from this script goes either to the log file or a tty,
1625
# so can't use "w*" colors.
1726

@@ -90,23 +99,46 @@ else
9099
NEEDS_REBOOT="false"
91100
fi
92101

93-
# Make sure the settings have been configured after an installation or upgrade.
102+
if [[ ${NEEDS_REBOOT} == "true" ]]; then
103+
set_allsky_status "${ALLSKY_STATUS_REBOOT_NEEDED}"
104+
doExit "${EXIT_ERROR_STOP}" "RebootNeeded" "" "The Pi needs to be rebooted."
105+
fi
106+
94107
# If the "lastchanged" setting is missing, the user needs to review/change the settings.
108+
# This will happen after an installation or upgrade, which also sets the Allsky status.
95109
LAST_CHANGED="$( settings ".lastchanged" )"
96110
if [[ -z ${LAST_CHANGED} ]]; then
97-
set_allsky_status "${ALLSKY_STATUS_NEEDS_CONFIGURATION}"
98-
echo "*** ===== Allsky needs to be configured before it can be used. See the WebUI." >&2
111+
STATUS="$( get_allsky_status )"
112+
if [[ ${STATUS} == "${ALLSKY_STATUS_REBOOT_NEEDED}" ]]; then
113+
# It's been rebooted and now we need to force "lastchanged" to be set.
114+
STATUS="${ALLSKY_STATUS_NEEDS_REVIEW}"
115+
fi
116+
117+
if [[ ${STATUS} == "${ALLSKY_STATUS_NEEDS_REVIEW}" ]]; then
118+
IMAGE_NAME="ReviewNeeded"
119+
MSG="Please review the settings on the WebUI's 'Allsky Settings' page"
120+
MSG+=" and make any necessary changes."
121+
WEBUI_MSG="Allsky settings need review"
122+
123+
elif [[ ${STATUS} == "${ALLSKY_STATUS_NEEDS_CONFIGURATION}" ]]; then
124+
IMAGE_NAME="ConfigurationNeeded"
125+
MSG="Allsky needs to be configured before it can be used. See the WebUI."
126+
WEBUI_MSG="Allsky needs to be configured"
127+
128+
else
129+
# I don't think we'll ever get here.
130+
MSG="ERROR: Unknown reason 'lastchanged' did not exist."
131+
WEBUI_MSG="${MSG}"
132+
IMAGE_NAME=""
133+
fi
99134
if [[ ${NEEDS_REBOOT} == "true" ]]; then
100-
echo "*** ===== The Pi also needs to be rebooted." >&2
101-
doExit "${EXIT_ERROR_STOP}" "ConfigurationNeeded" \
102-
"Allsky needs\nconfiguration\nand the Pi needs\na reboot" \
103-
"Allsky needs to be configured and then the Pi rebooted."
135+
MSG+=" The Pi also needs to be rebooted." >&2
136+
doExit "${EXIT_ERROR_STOP}" "${IMAGE_NAME}" \
137+
"" "${WEBUI_MSG} and then the Pi rebooted."
104138
else
105-
doExit "${EXIT_ERROR_STOP}" "ConfigurationNeeded" "" "Allsky needs to be configured."
139+
doExit "${EXIT_ERROR_STOP}" "${IMAGE_NAME}" "" "${WEBUI_MSG}."
106140
fi
107-
elif [[ ${NEEDS_REBOOT} == "true" ]]; then
108-
set_allsky_status "${ALLSKY_STATUS_REBOOT_NEEDED}"
109-
doExit "${EXIT_ERROR_STOP}" "RebootNeeded" "" "The Pi needs to be rebooted."
141+
[[ -n ${MSG} ]] && echo "*** ===== ${MSG}" >&2 # to the log
110142
fi
111143

112144
SEE_LOG_MSG="See ${ALLSKY_LOG}"
@@ -175,9 +207,6 @@ fi
175207

176208
USE_NOTIFICATION_IMAGES="$( settings ".notificationimages" )" || exit "${EXIT_ERROR_STOP}"
177209

178-
# Make sure we are not already running.
179-
pgrep "${ME}" | grep -v $$ | xargs "sudo kill -9" 2>/dev/null
180-
181210
# Get the list of connected cameras and make sure the one we want is connected.
182211
if [[ ${CAMERA_TYPE} == "ZWO" ]]; then
183212
RPi_COMMAND_TO_USE=""
@@ -222,9 +251,24 @@ if [[ ${CAMERA_TYPE} == "ZWO" ]]; then
222251
"WARNING:\n\nResetting USB bus\n${REASON}.\nAttempt ${NUM_USB_RESETS}."
223252

224253
SEARCH="${ZWO_VENDOR}:${ZWO_CAMERA_ID}"
225-
sudo "${ALLSKY_BIN}/uhubctl" --action off --exact --search "${SEARCH}"
254+
# Get the hub number the camera is on.
255+
local HUB="$( sudo "${ALLSKY_BIN}/uhubctl" --exact --search "${SEARCH}" |
256+
gawk -v Z="${SEARCH}" '
257+
BEGIN {hub = ""; }
258+
{
259+
if ($4 == "hub") {
260+
hub = $5;
261+
next;
262+
}
263+
if (index($0, Z) > 0) {
264+
print hub;
265+
exit(0);
266+
}
267+
}'
268+
)"
269+
sudo "${ALLSKY_BIN}/uhubctl" --action off --exact --search "${SEARCH}" --location "${HUB}"
226270
sleep 3 # give it a few seconds, plus, allow the notification images to be seen
227-
sudo "${ALLSKY_BIN}/uhubctl" --action on --exact --search "${SEARCH}"
271+
sudo "${ALLSKY_BIN}/uhubctl" --action on --exact --search "${SEARCH}" --location "${HUB}"
228272
}
229273

230274
else # RPi
@@ -259,14 +303,18 @@ fi
259303
# Make sure the current camera is supported and hasn't changed unexpectedly.
260304
CAM="${CAMERA_TYPE} ${CAMERA_NUMBER} ${CAMERA_MODEL}" # has TABS
261305
CCM="$( get_connected_camera_models --full "${CAMERA_TYPE}" )"
262-
read -r CC_TYPE CC_NUMBER CC_MODEL <<<"${CCM}"
263-
if ! echo -e "${CCM}" | grep --silent "${CAM}" ; then
306+
#shellcheck disable=SC2076
307+
if [[ ! ${CCM} =~ "${CAM}" ]]; then
308+
IFS=" " read -r CC_TYPE CC_NUMBER CC_MODEL CC_OTHER <<<"${CCM}"
309+
echo -e "Was: ${CAMERA_TYPE} ${CAMERA_NUMBER} ${CAMERA_MODEL}"
310+
echo -e "Now: ${CC_TYPE} ${CC_NUMBER} ${CC_MODEL} ${CC_OTHER}"
264311
# Something changed. validate_camera() displays the error message.
265312
if ! validate_camera "${CC_TYPE}" "${CC_MODEL}" "${CC_NUMBER}" ; then
266313
set_allsky_status "${ALLSKY_STATUS_CAMERA_CHANGED}"
267314
IMAGE_MSG="${ERROR_MSG_PREFIX}"
268315
IMAGE_MSG+="The camera changed."
269316
IMAGE_MSG+="\nCheck Camera Type\n& Model in the WebUI."
317+
reset_usb "Camera changed"
270318
doExit "${EXIT_ERROR_STOP}" "Error" "${IMAGE_MSG}"
271319
fi
272320
fi

assets/cameraNoise.psd

14 MB
Binary file not shown.

0 commit comments

Comments
 (0)