Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source tree restructure #535

Merged
merged 6 commits into from
Oct 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "sunwait-src"]
path = sunwait-src
[submodule "src/sunwait-src"]
path = src/sunwait-src
url = https://github.com/risacher/sunwait
85 changes: 0 additions & 85 deletions Makefile

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
85 changes: 33 additions & 52 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if [[ $EUID -eq 0 ]]; then
echo "This script must NOT be run as root" 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")
Expand All @@ -19,62 +20,42 @@ if [ "$DIR" != "$INSTALL_DIR" ] ; then
exit 1
fi

echo -en '\n'
echo -e "**********************************************"
echo "*** Welcome to the Allsky Camera installer ***"
echo -e "**********************************************"
echo -en '\n'

echo -en "${GREEN}* Dependencies installation\n${NC}"
sudo apt update && sudo apt -y install libopencv-dev libusb-dev libusb-1.0-0-dev ffmpeg gawk lftp jq imagemagick
echo -en '\n'

echo -en "${GREEN}* Compile allsky software\n${NC}"
make all
echo -en '\n'

# Make sure all scripts are executable
chmod 755 allsky.sh scripts/*.sh

echo -en "${GREEN}* Sunwait installation"
sudo install sunwait /usr/local/bin/
echo -en '\n'

echo -en "${GREEN}* Allow using the camera without root access\n${NC}"
sudo install -D -m 0644 asi.rules /etc/udev/rules.d/
sudo udevadm control -R
echo -en '\n'

echo -en "${GREEN}* Autostart script\n${NC}"
[ -e /etc/xdg/lxsession/LXDE-pi/autostart ] && sudo sed -i '/allsky.sh/d' /etc/xdg/lxsession/LXDE-pi/autostart
sed -i "s|User=pi|User=$USER|g" autostart/allsky.service
sed -i "s|/home/pi/allsky|$PWD|g" autostart/allsky.service
sudo install -D -m 0644 autostart/allsky.service /etc/systemd/system/
sudo rm -f /lib/systemd/system/allsky.service # remove file from prior version of AllSky
echo -en '\n'
echo
echo "**********************************************"
echo "*** Welcome to the Allsky Camera installer ***"
echo "**********************************************"
echo

echo -en "${GREEN}* Configure log rotation\n${NC}"
sudo install -D -m 0644 autostart/allsky /etc/logrotate.d/
sudo install -D -m 0644 autostart/allsky.conf /etc/rsyslog.d/
echo -en '\n'
echo -e "${GREEN}* Dependencies installation\n${NC}"
sudo make -C src deps
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo Installing dependencies failed\!
exit 1
fi
echo

echo -en "${GREEN}* Add ALLSKY_HOME environment variable\n${NC}"
echo "export ALLSKY_HOME=$PWD" | sudo tee /etc/profile.d/allsky.sh &> /dev/null
echo -en '\n'
echo -e "${GREEN}* Compile allsky software\n${NC}"
make -C src all
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo Compile failed\!
exit 1
fi
echo

echo -en "${GREEN}* Copy camera settings files\n${NC}"
[ ! -e settings_ZWO.json ] && cp settings_ZWO.json.repo settings_ZWO.json
[ ! -e settings_RPiHQ.json ] && cp settings_RPiHQ.json.repo settings_RPiHQ.json
[ ! -e config.sh ] && cp config.sh.repo config.sh
[ ! -e scripts/ftp-settings.sh ] && cp scripts/ftp-settings.sh.repo scripts/ftp-settings.sh
sudo chown -R $USER:$USER ./
sudo systemctl daemon-reload
sudo systemctl enable allsky.service
echo -en '\n'
echo -e "${GREEN}* Install allsky software\n${NC}"
sudo make -C src install
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo Install failed\!
exit 1
fi
echo

echo -en '\n'
echo -en "The Allsky Software is now installed. You should reboot the Raspberry Pi to finish the installation\n"
echo -en '\n'
echo
echo "The Allsky Software is now installed. You should reboot the Raspberry Pi to finish the installation"
echo
read -p "Do you want to reboot now? [y/n] " ans_yn
case "$ans_yn" in
[Yy]|[Yy][Ee][Ss]) sudo reboot now;;
Expand Down
181 changes: 181 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
platform = $(shell uname -m)
prefix = /

PDIR = $(shell dirname "$$PWD")
MYDIR = $(shell basename "$$PWD")
NLU = $(shell basename "$(PDIR)")
RIGHTPATH = 1

ifneq (src,$(MYDIR))
RIGHTPATH = 0
endif
ifneq (allsky,$(NLU))
RIGHTPATH = 0
endif

ifneq (1,$(RIGHTPATH))
@echo Unexpected directory structure.
@echo This should be in allsky/src directory.
else

.DEFAULT_GOAL := all

deps:
ifneq ($(shell id -u), 0)
@echo This must be ran with root permissions.
@echo Please run \'sudo make deps\'
else
@echo `date +%F\ %R:%S` Installing build dependencies...
@apt update && apt -y install libopencv-dev libusb-dev libusb-1.0-0-dev ffmpeg gawk lftp jq imagemagick
endif

USB=$(shell pkg-config --cflags --libs libusb-1.0)
ifeq (,$(USB))
$(error Did not find USB Libraries, try 'make deps')
endif

DEFS = -D_LIN -D_DEBUG -DGLIBC_20
CFLAGS = -Wall -Wno-psabi -g -O2 -lpthread
OPENCV = $(shell pkg-config --exists opencv && pkg-config --cflags --libs opencv || (pkg-config --exists opencv4 && pkg-config --cflags --libs opencv4))

ifeq (,$(OPENCV))
$(error Did not find any OpenCV Libraries, try 'make deps')
endif

ifeq ($(platform), armv6l)
CC = arm-linux-gnueabihf-g++
AR= arm-linux-gnueabihf-ar
CFLAGS += -march=armv6
CFLAGS += -lrt
ZWOSDK = -Llib/armv6 -I./include
endif

ifeq ($(platform), armv7l)
CC = arm-linux-gnueabihf-g++
AR= arm-linux-gnueabihf-ar
CFLAGS += -march=armv7 -mthumb
ZWOSDK = -Llib/armv7 -I./include
endif

#Ubuntu 20.04 added by Jos Wennmacker
ifeq ($(platform), aarch64)
CC = g++
AR= ar
ZWOSDK = -Llib/armv8 -I./include
endif

ifeq ($(platform), x86_64)
CC = g++
AR= ar
ZWOSDK = -Llib/x64 -I./include
endif

ifeq ($(platform), i386)
CC = g++
AR= ar
ZWOSDK = -Llib/x86 -I./include
endif

ifeq (,$(CC))
$(warning Could not identify the proper compiler for your platform.)
$(error Unknown platform $(platform))
endif

CFLAGS += $(DEFS) $(ZWOSDK)

all:capture capture_RPiHQ startrails keogram sunwait

sunwait:
@echo `date +%F\ %R:%S` Initializing sunwait submodule...
@git submodule init
@git submodule update
@echo `date +%F\ %R:%S` Building sunwait...
@$(MAKE) -C sunwait-src
@cp sunwait-src/sunwait .
@echo `date +%F\ %R:%S` Build of sunwait complete.

capture:capture.cpp
@echo `date +%F\ %R:%S` Building capture program...
@$(CC) capture.cpp -o capture $(CFLAGS) $(OPENCV) -lASICamera2 $(USB)
@echo `date +%F\ %R:%S` Build of capture complete.

capture_RPiHQ:capture_RPiHQ.cpp
@echo `date +%F\ %R:%S` Building capture_RPiHQ program...
@$(CC) capture_RPiHQ.cpp -o capture_RPiHQ $(CFLAGS) $(OPENCV)
@echo `date +%F\ %R:%S` Build of capture_RPiHQ complete.

startrails:startrails.cpp
@echo `date +%F\ %R:%S` Building startrails program...
@$(CC) startrails.cpp -o startrails $(CFLAGS) $(OPENCV)
@echo `date +%F\ %R:%S` Build of startrails complete.

keogram:keogram.cpp
@echo `date +%F\ %R:%S` Building keogram program...
@$(CC) keogram.cpp -o keogram $(CFLAGS) $(OPENCV)
@echo `date +%F\ %R:%S` Build of keogram complete.

install:
ifneq ($(shell id -u), 0)
$(error Please run \'sudo make install\')
else
@echo `date +%F\ %R:%S` Starting install...
@chmod 755 ../allsky.sh ../scripts/*.sh
@echo `date +%F\ %R:%S` Setting up udev rules...
@install -D -m 0644 ../config_repo/asi.rules /etc/udev/rules.d/
@udevadm control -R
@echo `date +%F\ %R:%S` Setting allsky to auto start...
ifneq ($(wildcard /etc/xdg/lxsession/LXDE-pi/autostart),)
@sed -i '/allsky.sh/d' /etc/xdg/lxsession/LXDE-pi/autostart
endif
@sed -i "s|User=pi|User=$(SUDO_USER)|g" ../config_repo/allsky.service
@sed -i "s|/home/pi/allsky|$(PDIR)|g" ../config_repo/allsky.service
@install -m 0644 ../config_repo/allsky.service /etc/systemd/system/
ifneq ($(wildcard /lib/systemd/system/allsky.service),)
@rm -f /lib/systemd/system/allsky.service
endif
@systemctl daemon-reload
@systemctl enable allsky
@echo `date +%F\ %R:%S` Setting up logging...
@install -D -m 0644 ../config_repo/allsky.logrotate /etc/logrotate.d/allsky
@install -D -m 0644 ../config_repo/allsky.rsyslog /etc/rsyslog.d/allsky.conf
@echo `date +%F\ %R:%S` Setting up home environment variable...
@echo "export ALLSKY_HOME=$(PDIR)" > /etc/profile.d/allsky.sh
ifeq ($(wildcard ../settings_ZWO.json),)
@echo `date +%F\ %R:%S` Copying default settings_ZWO.json
@install -m 0644 -o $(SUDO_USER) -g $(SUDO_USER) ../config_repo/settings_ZWO.json.repo ../settings_ZWO.json
endif
ifeq ($(wildcard ../settings_RPiHQ.json),)
@echo `date +%F\ %R:%S` Copying default settings_RPiHQ.json
@install -m 0644 -o $(SUDO_USER) -g $(SUDO_USER) ../config_repo/settings_RPiHQ.json.repo settings_RPiHQ.json
endif
ifeq ($(wildcard ../config.sh),)
@echo `date +%F\ %R:%S` Copying default config.sh
@install -m 0644 -o $(SUDO_USER) -g $(SUDO_USER) ../config_repo/config.sh.repo ../config.sh
endif
ifeq ($(wildcard ../variables.sh),)
@echo `date +%F\ %R:%S` Copying default config.sh
@install -m 0644 -o $(SUDO_USER) -g $(SUDO_USER) ../config_repo/variables.sh.repo ../variables.sh
endif
ifeq ($(wildcard ../scripts/ftp-settings.sh),)
@echo `date +%F\ %R:%S` Copying default ftp-settings.sh
@install -m 0644 -o $(SUDO_USER) -g $(SUDO_USER) ../scripts/ftp-settings.sh.repo ../scripts/ftp-settings.sh
endif
@echo `date +%F\ %R:%S` Copying binaries...
@install -o $(SUDO_USER) -g $(SUDO_USER) capture ../
@install -o $(SUDO_USER) -g $(SUDO_USER) keogram ../
@install -o $(SUDO_USER) -g $(SUDO_USER) startrails ../
@install sunwait /usr/local/bin/

@echo `date +%F\ %R:%S` Setting directory permissions...
@chown $(SUDO_USER):$(SUDO_USER) ./
@echo ""
@echo ""
@echo `date +%F\ %R:%S` It is recommended to reboot now, please issue \'sudo reboot\'
@echo ""
@echo ""
endif # sudo / root check

clean:
rm -f capture capture_RPiHQ startrails keogram

endif # Correct directory structure check
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/sunwait-src
Submodule sunwait-src added at 102cb4
Binary file removed sunwait
Binary file not shown.
Loading