Skip to content

Commit d52c5f8

Browse files
authored
Merge branch 'v2025.xx.xx' into 3312-support-sensor-temperature-on-rpi-cameras-that-support-it
2 parents a83bffa + c9167a1 commit d52c5f8

42 files changed

Lines changed: 557 additions & 481 deletions

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

allsky.sh

Lines changed: 53 additions & 15 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,20 +99,37 @@ else
9099
NEEDS_REBOOT="false"
91100
fi
92101

93-
# Make sure the settings have been configured after an installation or upgrade.
94102
# If the "lastchanged" setting is missing, the user needs to review/change the settings.
103+
# This will happen after an installation or upgrade, which also sets the Allsky status.
95104
LAST_CHANGED="$( settings ".lastchanged" )"
96105
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
106+
STATUS="$( get_allsky_status )"
107+
if [[ ${STATUS} == "${ALLSKY_STATUS_NEEDS_REVIEW}" ]]; then
108+
IMAGE_NAME="ReviewNeeded"
109+
MSG="Please review the settings on the WebUI's 'Allsky Settings' page"
110+
MSG+=" and make any necessary changes."
111+
WEBUI_MSG="Allsky settings need review"
112+
113+
elif [[ ${STATUS} == "${ALLSKY_STATUS_NEEDS_CONFIGURATION}" ]]; then
114+
IMAGE_NAME="ConfigurationNeeded"
115+
MSG="Allsky needs to be configured before it can be used. See the WebUI."
116+
WEBUI_MSG="Allsky needs to be configured"
117+
118+
else
119+
# I don't think we'll ever get here.
120+
MSG="ERROR: Unknown reason 'lastchanged' did not exist."
121+
WEBUI_MSG="${MSG}"
122+
IMAGE_NAME=""
123+
fi
99124
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."
125+
MSG+=" The Pi also needs to be rebooted." >&2
126+
doExit "${EXIT_ERROR_STOP}" "${IMAGE_NAME}" \
127+
"" "${WEBUI_MSG} and then the Pi rebooted."
104128
else
105-
doExit "${EXIT_ERROR_STOP}" "ConfigurationNeeded" "" "Allsky needs to be configured."
129+
doExit "${EXIT_ERROR_STOP}" "${IMAGE_NAME}" "" "${WEBUI_MSG}."
106130
fi
131+
echo "*** ===== ${MSG}" >&2 # to the log
132+
107133
elif [[ ${NEEDS_REBOOT} == "true" ]]; then
108134
set_allsky_status "${ALLSKY_STATUS_REBOOT_NEEDED}"
109135
doExit "${EXIT_ERROR_STOP}" "RebootNeeded" "" "The Pi needs to be rebooted."
@@ -175,9 +201,6 @@ fi
175201

176202
USE_NOTIFICATION_IMAGES="$( settings ".notificationimages" )" || exit "${EXIT_ERROR_STOP}"
177203

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

224247
SEARCH="${ZWO_VENDOR}:${ZWO_CAMERA_ID}"
225-
sudo "${ALLSKY_BIN}/uhubctl" --action off --exact --search "${SEARCH}"
248+
# Get the hub number the camera is on.
249+
local HUB="$( sudo "${ALLSKY_BIN}/uhubctl" --exact --search "${SEARCH}" |
250+
gawk -v Z="${SEARCH}" '
251+
BEGIN {hub = ""; }
252+
{
253+
if ($4 == "hub") {
254+
hub = $5;
255+
next;
256+
}
257+
if (index($0, Z) > 0) {
258+
print hub;
259+
exit(0);
260+
}
261+
}'
262+
)"
263+
sudo "${ALLSKY_BIN}/uhubctl" --action off --exact --search "${SEARCH}" --location "${HUB}"
226264
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}"
265+
sudo "${ALLSKY_BIN}/uhubctl" --action on --exact --search "${SEARCH}" --location "${HUB}"
228266
}
229267

230268
else # RPi

config_repo/Makefile

Lines changed: 44 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,83 @@
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
HOMEDIR = $(shell dirname "$$PWD")
4+
CONFIGDIR = ${HOMEDIR}/config
115
SCRIPTSDIR = ${HOMEDIR}/scripts
6+
UTILITIESDIR = ${SCRIPTSDIR}/utilities
7+
# TODO: get from variables.sh
8+
NORESTARTCODES = 100 101
9+
LIBSYSTEMDIR = /lib/systemd/system
1210

1311
.DEFAULT_GOAL := all
1412

1513
ROOTCHECK=$(shell id -u)
16-
ifneq ($(ROOTCHECK),0)
17-
ifeq ($(PKGBUILD),1)
18-
ROOTCHECK=0
19-
endif
20-
endif
21-
22-
ifeq ($(PKGBUILD),)
23-
PKGBUILD=0
24-
endif
25-
2614

2715
ENVFILE := env.json
28-
UNINSTALLFILES := $(DESTDIR)$(sysconfdir)/logrotate.d/allsky $(DESTDIR)$(sysconfdir)/rsyslog.d/allsky.conf $(DESTDIR)$(sysconfdir)/systemd/system/allsky.service $(DESTDIR)$(sysconfdir)/systemd/system/allskyperiodic.service
16+
UNINSTALLFILES := /etc/logrotate.d/allsky /etc/rsyslog.d/allsky.conf /etc/systemd/system/allsky.service /etc/systemd/system/allskyperiodic.service
2917

3018
%:
31-
@echo `date +%F\ %R:%S` nothing to do for $@
19+
@echo "`date +%F\ %R:%S` nothing to do for $@"
3220

3321
ifneq ($(ROOTCHECK), 0)
3422
install uninstall:
35-
@echo This must be run with root permissions.
36-
@echo Please run \'sudo make $@\'
23+
@echo "This must be run with root permissions."
24+
@echo "Please run 'sudo make $@'."
3725
else # Root check passed
3826

3927
uninstall:
40-
@echo `date +%F\ %R:%S` Removing installed files: $(UNINSTALLFILES)
28+
@echo "`date +%F\ %R:%S` Removing installed files: $(UNINSTALLFILES)"
4129
@rm -f $(UNINSTALLFILES)
42-
@echo `date +%F\ %R:%S` Complete.
43-
@echo `date +%F\ %R:%S` NOTE: Config files were \-NOT\- removed.
44-
@echo `date +%F\ %R:%S` To remove config files, please run \'sudo make remove_configs\'
30+
@echo "`date +%F\ %R:%S` Complete."
31+
@echo "`date +%F\ %R:%S` NOTE: Config files were -NOT- removed."
32+
@echo "`date +%F\ %R:%S` To remove config files, please run 'sudo make remove_configs'."
4533
.PHONY : uninstall
4634

47-
ifeq ($(PKGBUILD),1)
48-
49-
remove_configs:
50-
@echo `date +%F\ %R:%S` Removing config path and files $(DESTDIR)$(sysconfigdir)/allsky
51-
@rm -rf $(DESTDIR)$(sysconfigdir)/allsky
52-
53-
createDirs:
54-
@echo `date +%F\ %R:%S` Creating directory structures...
55-
@if [ ! -e $(DESTDIR)$(sysconfdir)/allsky ]; then mkdir -p $(DESTDIR)$(sysconfdir)/allsky; fi
56-
@if [ ! -e $(DESTDIR)$(sysconfdir)/profile.d ]; then mkdir -p $(DESTDIR)$(sysconfdir)/profile.d; fi
57-
@if [ ! -e $(DESTDIR)$(sysconfdir)/systemd/system ]; then mkdir -p $(DESTDIR)$(sysconfdir)/systemd/system; fi
58-
@if [ ! -e $(DESTDIR)$(sysconfdir)/udev/rules.d ]; then mkdir -p $(DESTDIR)$(sysconfdir)/udev/rules.d; fi
59-
.PHONY : createDirs
60-
61-
$(ENVFILE):
62-
@if [ ! -e $(DESTDIR)$(sysconfdir)/allsky/$@ ]; then \
63-
echo `date +%F\ %R:%S` Copying default $@; \
64-
cp $@.repo > env; \
65-
install -m 0664 env $(HOMEDIR)/$@; \
66-
rm -f env; \
67-
fi
68-
# TODO: In PKGBUILD mode, where is the "allsky" directory? $(ENVFILE) needs to go in it.
69-
# Is $(HOMEDIR) the correct location, or should it be $(DESTDIR)$(sysconfdir)/allsky ?
70-
.PHONY : $(ENVFILE)
71-
72-
install: createDirs $(ENVFILE)
73-
@echo `date +%F\ %R:%S` Setting up udev rules...
74-
@install -D -m 0644 asi.rules $(DESTDIR)$(sysconfdir)/udev/rules.d/
75-
@echo `date +%F\ %R:%S` Setting up logging...
76-
@install -D -m 0644 allsky.logrotate.repo $(DESTDIR)$(sysconfdir)/logrotate.d/allsky
77-
@install -D -m 0644 allsky.rsyslog.repo $(DESTDIR)$(sysconfdir)/rsyslog.d/allsky.conf
78-
@echo `date +%F\ %R:%S` Setting allsky to auto start...
79-
@sed -e "s|XX_ALLSKY_OWNER_XX|allsky|" -e "s|XX_ALLSKY_HOME_XX|$(bindir)|" allsky.service.repo > allsky.service
80-
@install -m 0644 allsky.service $(DESTDIR)$(sysconfdir)/systemd/system/
81-
@rm -f allsky.service
82-
@echo `date +%F\ %R:%S` Setting up home environment variable...
83-
@echo "export ALLSKY_TMP=/tmp\nexport ALLSKY_CONFIG=$(DESTDIR)$(sysconfdir)/allsky\nexport ALLSKY_SCRIPTS=$(DESTDIR)$(libexecdir)\nexport ALLSKY_NOTIFICATION_IMAGES=$(DESTDIR)$(sharedir)\nexport ALLSKY_IMAGES=/home/allsky/images/\nPATH=${PATH}:${DESTDIR}$(libexedir)" > $(DESTDIR)$(sysconfdir)/profile.d/allsy.sh
84-
85-
86-
else # Not in package build mode ######################################
87-
8835
remove_configs:
89-
@echo `date +%F\ %R:%S` Removing config path and files ../config
90-
@rm -rf ../config
36+
@echo "`date +%F\ %R:%S` Removing config path and files $(CONFIGDIR)"
37+
@rm -rf $(CONFIGDIR)
9138
.PHONY : remove_configs
9239

9340
createDirs:
94-
@echo `date +%F\ %R:%S` Creating directory structures...
95-
@if [ ! -e ../config ]; then mkdir -p ../config; chown $(SUDO_USER):$(SUDO_USER) ../config; fi
41+
@echo "`date +%F\ %R:%S` Creating directory structures..."
42+
@if [ ! -e $(CONFIGDIR) ]; then \
43+
mkdir -p $(CONFIGDIR); \
44+
chown $(SUDO_USER):$(SUDO_USER) $(CONFIGDIR); \
45+
fi
9646
.PHONY : createDirs
9747

9848
install: createDirs
99-
@echo `date +%F\ %R:%S` Setting up udev rules...
100-
@install -D -m 0644 asi.rules $(DESTDIR)$(sysconfdir)/udev/rules.d/
101-
@echo `date +%F\ %R:%S` Setting up logging...
102-
@install -D -m 0644 allsky.logrotate.repo $(DESTDIR)$(sysconfdir)/logrotate.d/allsky
103-
@install -D -m 0644 allsky.rsyslog.repo $(DESTDIR)$(sysconfdir)/rsyslog.d/allsky.conf
49+
@echo "`date +%F\ %R:%S` Setting up udev rules..."
50+
@install -D -m 0644 asi.rules /etc/udev/rules.d/
51+
@echo "`date +%F\ %R:%S` Setting up logging..."
52+
@install -D -m 0644 allsky.logrotate.repo /etc/logrotate.d/allsky
53+
@install -D -m 0644 allsky.rsyslog.repo /etc/rsyslog.d/allsky.conf
10454
@udevadm control -R
10555
@udevadm trigger
106-
@echo `date +%F\ %R:%S` Setting allsky to auto start...
56+
@echo "`date +%F\ %R:%S` Setting allsky to auto start..."
10757
@if [ -e /etc/xdg/lxsession/LXDE-pi/autostart ]; then \
10858
sed -i '/allsky.sh/d' /etc/xdg/lxsession/LXDE-pi/autostart; fi
109-
@# Don't use the /lib/systemd/system directory
110-
@sed -e "s|XX_ALLSKY_OWNER_XX|$(SUDO_USER)|" -e "s|XX_ALLSKY_HOME_XX|$(HOMEDIR)|" -e "s|XX_ALLSKY_SCRIPTS_XX|$(SCRIPTSDIR)|" allsky.service.repo > allsky.service
111-
@install -m 0644 allsky.service $(DESTDIR)$(sysconfdir)/systemd/system/
59+
@# Don't use the $(LIBSYSTEMDIR) directory
60+
@sed -e "s|XX_ALLSKY_OWNER_XX|$(SUDO_USER)|" \
61+
-e "s|XX_ALLSKY_HOME_XX|$(HOMEDIR)|" \
62+
-e "s|XX_NO_RESTART_CODES_XX|$(NORESTARTCODES)|" \
63+
-e "s|XX_ALLSKY_UTILITIES_XX|$(UTILITIESDIR)|" \
64+
allsky.service.repo > allsky.service
65+
@install -m 0644 allsky.service /etc/systemd/system/
11266
@rm -f allsky.service
113-
@if [ -e /lib/systemd/system/allsky.service ]; then rm -f /lib/systemd/system/allsky.service; fi
114-
@sed -e "s|XX_ALLSKY_OWNER_XX|$(SUDO_USER)|" -e "s|XX_ALLSKY_SCRIPTS_XX|$(SCRIPTSDIR)|" allskyperiodic.service.repo > allskyperiodic.service
115-
@install -m 0644 allskyperiodic.service $(DESTDIR)$(sysconfdir)/systemd/system/
67+
@if [ -e $(LIBSYSTEMDIR)/allsky.service ]; then rm -f $(LIBSYSTEMDIR)/allsky.service; fi
68+
@sed -e "s|XX_ALLSKY_OWNER_XX|$(SUDO_USER)|" \
69+
-e "s|XX_NO_RESTART_CODES_XX|$(NORESTARTCODES)|" \
70+
-e "s|XX_ALLSKY_SCRIPTS_XX|$(SCRIPTSDIR)|" \
71+
allskyperiodic.service.repo > allskyperiodic.service
72+
@install -m 0644 allskyperiodic.service /etc/systemd/system/
11673
@rm -f allskyperiodic.service
117-
@if [ -e /lib/systemd/system/allskyperiodic.service ]; then rm -f /lib/systemd/system/allskyperiodic.service; fi
74+
@if [ -e $(LIBSYSTEMDIR)/allskyperiodic.service ]; then rm -f $(LIBSYSTEMDIR)/allskyperiodic.service; fi
11875
@systemctl daemon-reload
11976
@systemctl enable allsky
12077
@systemctl enable allskyperiodic
121-
@echo `date +%F\ %R:%S` Setting up ALLSKY_HOME environment variable...
122-
@echo "export ALLSKY_HOME=$(HOMEDIR)\nPATH=${PATH}:$(SCRIPTSDIR)" > $(DESTDIR)$(sysconfdir)/profile.d/allsky.sh
78+
@echo "`date +%F\ %R:%S` Setting up ALLSKY_HOME environment variable..."
79+
@echo "export ALLSKY_HOME=$(HOMEDIR)\nPATH=${PATH}:$(SCRIPTSDIR)" > /etc/profile.d/allsky.sh
80+
12381
.PHONY : install
124-
endif # Package build check
82+
12583
endif # Root check

config_repo/allsky.service.repo

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ ExecStart=XX_ALLSKY_HOME_XX/allsky.sh
99
SyslogIdentifier=allsky
1010
Restart=on-success
1111
RestartSec=2
12-
; exit status 100 and higher mean a fatal error the user needs to fix, so don't restart
13-
RestartPreventExitStatus=100 101
12+
; These exit code are fatal.
13+
RestartPreventExitStatus=XX_NO_RESTART_CODES_XX
14+
1415
; XXX RestartKillSignal is not recognized by the systemd that comes with Buster (not sure about Bullseye),
1516
; so use ExecReload instead.
1617
; RestartKillSignal=SIGUSR1
17-
ExecReload=XX_ALLSKY_SCRIPTS_XX/reload.sh $MAINPID
18+
ExecReload=XX_ALLSKY_UTILITIES_XX/reload.sh $MAINPID
1819

1920
[Install]
2021
WantedBy=multi-user.target

config_repo/allskyperiodic.service.repo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ ExecStart=XX_ALLSKY_SCRIPTS_XX/periodic.sh
99
SyslogIdentifier=allskperiodic
1010
Restart=on-success
1111
RestartSec=5
12-
; exit status 100 and higher mean a fatal error the user needs to fix, so don't restart
13-
RestartPreventExitStatus=100 101
12+
; These exit code are fatal.
13+
RestartPreventExitStatus=XX_NO_RESTART_CODES_XX
1414

1515
[Install]
1616
WantedBy=multi-user.target

0 commit comments

Comments
 (0)