Skip to content

Commit

Permalink
Merge branch 'release/v0.1.0'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/build.yml
  • Loading branch information
matteocarnelos committed Apr 28, 2022
2 parents 03f4887 + 12edd18 commit d3003af
Show file tree
Hide file tree
Showing 30 changed files with 185 additions and 196 deletions.
61 changes: 61 additions & 0 deletions .build/sailtrack-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

# Check arguments
if [ -z "$1" ]; then
echo "sailtrack-build: missing argument: DIETPI_IMG_NAME"
echo "Usage: sailtrack-build DIETPI_IMG_NAME OUTPUT_IMG_NAME"
exit 1
fi

if [ -z "$2" ]; then
echo "sailtrack-build: missing argument: OUTPUT_IMG_NAME"
echo "Usage: sailtrack-build DIETPI_IMG_NAME OUTPUT_IMG_NAME"
exit 1
fi

# Set variables
DIETPI_IMG_NAME=$1
OUTPUT_IMG_NAME=$2

# Download and extract image
wget -N "https://dietpi.com/downloads/images/$DIETPI_IMG_NAME.7z" -P /tmp/sailtrack-build || exit 1
7z e -aoa -o"/tmp/sailtrack-build/$DIETPI_IMG_NAME" "/tmp/sailtrack-build/$DIETPI_IMG_NAME.7z"

# Mount image
FP_LOOP=$(losetup --show -f -P "/tmp/sailtrack-build/$DIETPI_IMG_NAME/$DIETPI_IMG_NAME.img")
mkdir /tmp/sailtrack-build/mnt
mount "${FP_LOOP}p2" /tmp/sailtrack-build/mnt
mount "${FP_LOOP}p1" /tmp/sailtrack-build/mnt/boot

# Copy files
cp -v LICENSE /tmp/sailtrack-build/mnt/boot/sailtrack-LICENSE.txt
cp -v README.md /tmp/sailtrack-build/mnt/boot/sailtrack-README.md
cp -v dietpi.txt /tmp/sailtrack-build/mnt/boot/dietpi.txt
cp -v Automation_Custom_Script.sh /tmp/sailtrack-build/mnt/boot/Automation_Custom_Script.sh
cp -vr sailtrack /tmp/sailtrack-build/mnt/boot/sailtrack
cp -vrT rootfs /tmp/sailtrack-build/mnt

# Unmount image
umount -R /tmp/sailtrack-build/mnt
losetup -d "$FP_LOOP"

# Rename image
mv "/tmp/sailtrack-build/$DIETPI_IMG_NAME/$DIETPI_IMG_NAME.img" "/tmp/sailtrack-build/$DIETPI_IMG_NAME/$OUTPUT_IMG_NAME.img"

# Update hashes
echo -n "Generating hashes..."
cat << _EOF_ > "/tmp/sailtrack-build/$DIETPI_IMG_NAME/hash.txt"
FILE: $OUTPUT_IMG_NAME.img
DATE: $(date -u)
MD5: $(md5sum "/tmp/sailtrack-build/$DIETPI_IMG_NAME/$OUTPUT_IMG_NAME.img" | mawk '{print $1}')
SHA1: $(sha1sum "/tmp/sailtrack-build/$DIETPI_IMG_NAME/$OUTPUT_IMG_NAME.img" | mawk '{print $1}')
SHA256: $(sha256sum "/tmp/sailtrack-build/$DIETPI_IMG_NAME/$OUTPUT_IMG_NAME.img" | mawk '{print $1}')
_EOF_
echo "done"

# Update README
cp -v README.md "/tmp/sailtrack-build/$DIETPI_IMG_NAME"

# Create archive
(( $(free -m | mawk '/Mem:/{print $2}') < 1750 && $(nproc) > 2 )) && limit_threads='-mmt2'
7z a -m0=lzma2 -mx=9 $limit_threads "$OUTPUT_IMG_NAME.7z" "/tmp/sailtrack-build/$DIETPI_IMG_NAME/*"
63 changes: 0 additions & 63 deletions .github/workflows/build.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish GitHub Release

on:
push:
tags:
- 'v*.*.*'

jobs:
publish:
runs-on: ubuntu-latest
env:
DIETPI_IMG_NAME: DietPi_RPi-ARMv8-Bullseye
OUTPUT_IMG_NAME: SailTrack-Core_RPi-ARMv8-Bullseye
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run SailTrack-Build
run: sudo ./.build/sailtrack-build ${{ env.DIETPI_IMG_NAME }} ${{ env.OUTPUT_IMG_NAME }}

- name: Publish release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.OUTPUT_IMG_NAME }}.7z
generate_release_notes: true
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,3 @@ $RECYCLE.BIN/
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/macos,windows,linux,python,pycharm+all,visualstudiocode

# Patch: Include var/ and lib/ folders in rootfs
!rootfs/**/var/
!rootfs/**/lib/
52 changes: 21 additions & 31 deletions Automation_Custom_Script.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,32 @@
. /boot/dietpi/func/dietpi-globals

# Configure WiFi Hotspot
/boot/dietpi/func/dietpi-set_hardware wifimodules onboard_enable
/boot/dietpi/func/dietpi-set_hardware wificountrycode "$(sed -n '/^[[:blank:]]*AUTO_SETUP_NET_WIFI_COUNTRY_CODE=/{s/^[^=]*=//p;q}' /boot/dietpi.txt)"

# Configure RTC Module
G_AGP fake-hwclock
G_CONFIG_INJECT "dtoverlay=i2c-rtc,ds3231" "dtoverlay=i2c-rtc,ds3231" /boot/config.txt
G_EXEC sed -i "/systemd/,/fi/s/^/#/" /lib/udev/hwclock-set
G_EXEC sed -i "/--systz/s/^/#/" /lib/udev/hwclock-set

# Install packages
G_AGI avahi-daemon
G_AGI telegraf
G_EXEC pip3 install -r /boot/sailtrack/sailtrackd/requirements.txt
# Configure X708 HAT
G_CONFIG_INJECT "alias poweroff=/boot/sailtrack/sailtrack-x708_softsd" "alias poweroff=/boot/sailtrack/sailtrack-x708_softsd" /etc/bash.bashrc

# Remove unused services
G_EXEC rm /etc/systemd/system/dietpi-vpn.service
G_EXEC rm /etc/systemd/system/dietpi-cloudshell.service

# Merge filesystem
G_EXEC cp -rT /boot/rootfs /
G_EXEC rm -r /boot/rootfs
# Uninstall OpenSSH Client
/boot/dietpi/dietpi-software uninstall 0

# Install Telegraf
G_AGI telegraf

# Enable services
for s in /etc/systemd/system/sailtrack*.service; do G_EXEC systemctl enable "$s"; done
G_EXEC systemctl enable sailtrack-x708_asd
G_EXEC systemctl enable sailtrack-x708_pwr
G_CONFIG_INJECT "+ telegraf" "+ telegraf" /boot/dietpi/.dietpi-services_include_exclude
for s in /etc/systemd/system/sailtrackd*.service; do
servicename=$(basename "$s" .service)
G_CONFIG_INJECT "+ $servicename" "+ $servicename" /boot/dietpi/.dietpi-services_include_exclude
/boot/dietpi/dietpi-services dietpi_controlled "$servicename"
done
/boot/dietpi/dietpi-services dietpi_controlled telegraf
G_CONFIG_INJECT "+ sailtrack-status" "+ sailtrack-status" /boot/dietpi/.dietpi-services_include_exclude
G_EXEC /boot/dietpi/dietpi-services dietpi_controlled telegraf
G_EXEC /boot/dietpi/dietpi-services dietpi_controlled sailtrack-status

# Configure DietPi Banner
index=0
for i in 1 1 1 0 0 1 0 0 0 0 0 0 0 0; do
echo "aENABLED[$((index++))]=$i" >> /boot/dietpi/.dietpi-banner
settings=(1 1 1 0 0 1 0 1 0 0 0 0 0 0 0 0)
for i in "${!settings[@]}"; do
G_CONFIG_INJECT "aENABLED\[$i]=" "aENABLED[$i]=${settings[$i]}" /boot/dietpi/.dietpi-banner
done

# Remove DietPi-VPN
G_EXEC rm /etc/systemd/system/dietpi-vpn.service
# Reboot after first boot is completed
(while [ -f "/root/AUTO_CustomScript.sh" ]; do sleep 1; done; /usr/sbin/reboot) > /dev/null 2>&1 &

# Reboot
(while [ "$(</boot/dietpi/.install_stage)" != 2 ]; do sleep 1; done; /usr/sbin/reboot) > /dev/null 2>&1 &
55 changes: 26 additions & 29 deletions dietpi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AUTO_SETUP_ACCEPT_LICENSE=1
AUTO_SETUP_LOCALE=C.UTF-8

# Keyboard Layout eg: "gb" / "us" / "de" / "fr"
AUTO_SETUP_KEYBOARD_LAYOUT=us
AUTO_SETUP_KEYBOARD_LAYOUT=it

# Timezone eg: "Europe/London" / "America/New_York" | Full list (TZ*): https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
AUTO_SETUP_TIMEZONE=Europe/Rome
Expand All @@ -27,7 +27,7 @@ AUTO_SETUP_TIMEZONE=Europe/Rome
AUTO_SETUP_NET_ETHERNET_ENABLED=1
AUTO_SETUP_NET_WIFI_ENABLED=0

# Force ethernet speeds: 0=automatic speed | 10 = 10Mbit | 100 = 100Mbit etc
# Force Ethernet speeds: 0=automatic speed | 10 = 10Mbit | 100 = 100Mbit etc
# - This is mainly aimed at PINE A64 which may have an HW issue that causes unstable 1Gbit link.
AUTO_SETUP_NET_ETH_FORCE_SPEED=0

Expand All @@ -47,13 +47,16 @@ AUTO_SETUP_DHCP_TO_STATIC=0
# Hostname
AUTO_SETUP_NET_HOSTNAME=sailtrack-core

# Delay service starts at boot until network is established: 0=disabled | 1=enabled
AUTO_SETUP_BOOT_WAIT_FOR_NETWORK=1

##### Misc Options #####
# Swap space size to generate: 0 => disable | 1 => auto | 2 and up => size in MiB
AUTO_SETUP_SWAPFILE_SIZE=1
# Swap space location: "zram" => swap space on /dev/zram0 (auto-size = 50% of RAM size) | /path/to/file => swap file at location (auto-size = 2 GiB minus RAM size)
AUTO_SETUP_SWAPFILE_LOCATION=/var/swap

# Set to "1" to disable HDMI output (and GPU/VPU where supported) for supported devices: RPi, Odroid C1, Odroid C2
# Set to "1" to disable HDMI/video output and framebuffers on Raspberry Pi, to reduce power consumption and memory usage: Works on RPi only!
AUTO_SETUP_HEADLESS=1

# Unmask (enable) systemd-logind service (including dbus), which is masked by default on DietPi
Expand All @@ -79,15 +82,12 @@ AUTO_SETUP_BACKUP_RESTORE=0
# SSH server choice: 0=none/custom | -1=Dropbear | -2=OpenSSH
AUTO_SETUP_SSH_SERVER_INDEX=-2

# File server choice: 0=none/custom | -1=ProFTP | -2=Samba
AUTO_SETUP_FILE_SERVER_INDEX=0

# Logging mode choice: 0=none/custom | -1=RAMlog 1h clear | -2=RAMlog 1h save clear | -3=rsyslog + logrotate
AUTO_SETUP_LOGGING_INDEX=-1
# RAMlog max tmpfs size (MB). 50MB should be fine for single use. 200MB+ for heavy webserver and access log etc.
AUTO_SETUP_RAMLOG_MAXSIZE=50

# Webserver preference: 0=Apache2 | -1=Nginx | -2=Lighttpd
# Webserver preference: 0=Apache | -1=Nginx | -2=Lighttpd
# - This defines the webserver to install (only) when another selected software requires one.
# - It won't be installed if no other software requires a webserver and a manual webserver stack selection will override it.
AUTO_SETUP_WEB_SERVER_INDEX=-2
Expand All @@ -102,7 +102,7 @@ AUTO_SETUP_DESKTOP_INDEX=0
# - It won't be installed if no desktop is installed and a manual browser selection will override it.
AUTO_SETUP_BROWSER_INDEX=-1

# DietPi-Autostart: 0=Console | 7=Console autologin | 1=Kodi | 2=Desktop autologin | 16=Desktop | 4=OpenTyrian | 5=DietPi-Cloudshell | 6=Amiberry fast boot | 8=Amiberry standard boot | 9=DDX-Rebirth | 10=CAVA Spectrum | 11=Chromium kiosk | 14=Custom autostart service
# DietPi-Autostart: 0=Console | 7=Console autologin | 1=Kodi | 2=Desktop autologin | 16=Desktop | 4=OpenTyrian | 5=DietPi-CloudShell | 6=Amiberry fast boot | 8=Amiberry standard boot | 9=DDX-Rebirth | 10=CAVA Spectrum | 11=Chromium kiosk | 14=Custom script (background) | 17=Custom script (foreground)
# - This will be effective on 2nd boot, after firstrun update and installs have been done.
# - Related software titles must be installed either on firstrun installs or via AUTO_SETUP_AUTOMATED=1 + AUTO_SETUP_INSTALL_SOFTWARE_ID (see below).
AUTO_SETUP_AUTOSTART_TARGET_INDEX=0
Expand All @@ -113,26 +113,25 @@ AUTO_SETUP_AUTOSTART_LOGIN_USER=root

##### Non-interactive Firstrun Setup #####
# On first login, run update, initial setup and software installs without any user input
# - Setting this to "1" is required for below settings to take effect
# - It is HIGHLY recommended to also set CONFIG_BOOT_WAIT_FOR_NETWORK=2, to force infinite wait for network connection during boot and prevent connection timeout errors.
# - Setting this to "1" indicates that you accept the DietPi GPLv2 license, available at /boot/dietpi-LICENSE.txt, superseding any setting of AUTO_SETUP_ACCEPT_LICENSE.
# - Setting this to "1" is required for AUTO_SETUP_GLOBAL_PASSWORD and AUTO_SETUP_INSTALL_SOFTWARE_ID.
# - Setting this to "1" indicates that you accept the DietPi GPLv2 license, available at /boot/dietpi-LICENSE.txt, superseding AUTO_SETUP_ACCEPT_LICENSE.
AUTO_SETUP_AUTOMATED=1

# Global Password to be applied for the system
# - Requires AUTO_SETUP_AUTOMATED=1
# - Affects "root" and "dietpi" users login passwords and is used by dietpi-software as default for software installs which require a password.
# - On first dietpi-software execution, the password is removed from this file and instead encrypted and saved to rootfs.
# - WARN: We cannot guarantee that all software options can handle special characters like \"$.
AUTO_SETUP_GLOBAL_PASSWORD=dietpi

# Software to automatically install
# - Requires AUTO_SETUP_AUTOMATED=1
# - List of available software IDs: https://github.com/MichaIng/DietPi/wiki/DietPi-Software-list
# - Add as many entries as you wish, one each line.
# - DietPi will automatically install all pre-reqs (e.g. ALSA/X11 for desktops etc)
# - DietPi will automatically install all dependencies, like ALSA/X11 for desktops etc.
# - E.g. the following (without the leading "#") will install the LXDE desktop automatically on first boot:
#AUTO_SETUP_INSTALL_SOFTWARE_ID=23
AUTO_SETUP_INSTALL_SOFTWARE_ID=130 # Python 3 + Pip
AUTO_SETUP_INSTALL_SOFTWARE_ID=72 # I2C
AUTO_SETUP_INSTALL_SOFTWARE_ID=69 # RPi.GPIO
AUTO_SETUP_INSTALL_SOFTWARE_ID=60 # WiFi Hotspot
AUTO_SETUP_INSTALL_SOFTWARE_ID=123 # Mosquitto
AUTO_SETUP_INSTALL_SOFTWARE_ID=74 # InfluxDB
Expand All @@ -152,9 +151,9 @@ SURVEY_OPTED_IN=0
CONFIG_CPU_GOVERNOR=schedutil
# Ondemand Sampling Rate | Min value: 10000 microseconds (10ms)
CONFIG_CPU_ONDEMAND_SAMPLE_RATE=25000
# Ondemand Sampling Down Factor: Samling Rate * Down Factor / 1000 = ms (40 = 1000ms when sampling rate is 25000)
# Ondemand Sampling Down Factor: Sampling Rate * Down Factor / 1000 = ms (40 = 1000ms when sampling rate is 25000)
CONFIG_CPU_ONDEMAND_SAMPLE_DOWNFACTOR=40
# Throttle Up Percentage: Percentage of average CPU usage during samling rate at which CPU will be throttled up/down
# Throttle Up Percentage: Percentage of average CPU usage during sampling rate at which CPU will be throttled up/down
CONFIG_CPU_USAGE_THROTTLE_UP=50

# CPU Frequency Limits: Disabled=disabled
Expand All @@ -174,9 +173,6 @@ CONFIG_PROXY_PORT=8080
CONFIG_PROXY_USERNAME=
CONFIG_PROXY_PASSWORD=

# Delay boot until network is established: 0=disabled | 1=10 second wait max (default) | 2=infinite wait
CONFIG_BOOT_WAIT_FOR_NETWORK=2

# Connection timeout in seconds, before G_CHECK_URL assumes the URL is dead. Increase if you have a "flaky" connection or slow DNS resolver.
# - Set this to "0" to allow unlimited time, however this is not recommended to avoid unlimited hanging background scripts, e.g. daily DietPi update check.
# - A negative or non-integer value will result in the default of 10 seconds.
Expand Down Expand Up @@ -214,14 +210,11 @@ CONFIG_LCDPANEL=none
# IPv6
CONFIG_ENABLE_IPV6=1

# Prefer IPv4 with APT and wget, NB: This has no effect if IPv6 is disabled anyway!
CONFIG_PREFER_IPV4=1

# APT mirrors which are applied to /etc/apt/sources.list | Values here will also be applied during 1st run setup
# - Raspbian: https://www.raspbian.org/RaspbianMirrors
CONFIG_APT_RASPBIAN_MIRROR=https://raspbian.mirror.garr.it/mirrors/raspbian/raspbian/
CONFIG_APT_RASPBIAN_MIRROR=http://raspbian.raspberrypi.org/raspbian/
# - Debian: https://www.debian.org/mirror/official#list
CONFIG_APT_DEBIAN_MIRROR=https://debian.mirror.garr.it/debian/
CONFIG_APT_DEBIAN_MIRROR=https://deb.debian.org/debian/

# NTP mirror, applied to /etc/ntp.conf
# - For a full list, please see: https://www.ntppool.org/zone/@
Expand All @@ -231,10 +224,6 @@ CONFIG_NTP_MIRROR=debian.pool.ntp.org
#------------------------------------------------------------------------------------------------------
##### DietPi-Software settings #####
#------------------------------------------------------------------------------------------------------
# Enter your EmonCMS.org write API key here. It will be applied automatically during EmonPi/Hub install.
# - E.g.: SOFTWARE_EMONHUB_APIKEY=b4dfmk2o203mmxx93a
SOFTWARE_EMONHUB_APIKEY=

# VNC Server
SOFTWARE_VNCSERVER_WIDTH=1280
SOFTWARE_VNCSERVER_HEIGHT=720
Expand All @@ -254,7 +243,7 @@ SOFTWARE_NEXTCLOUD_DATADIR=/mnt/dietpi_userdata/nextcloud_data
SOFTWARE_WIFI_HOTSPOT_SSID=SailTrack-Net
# - Key requires a minimum of 8 characters
SOFTWARE_WIFI_HOTSPOT_KEY=sailtracknet
SOFTWARE_WIFI_HOTSPOT_CHANNEL=3
SOFTWARE_WIFI_HOTSPOT_CHANNEL=1

# X.org
# - DPI 96(default) 120(+25%) 144(+50%) 168(+75%) 192(+100%)
Expand Down Expand Up @@ -283,6 +272,14 @@ SOFTWARE_HOMEASSISTANT_PIP_DEPS=
# https://rancher.com/docs/k3s/latest/en/installation/install-options/#configuration-file
SOFTWARE_K3S_EXEC=

# DietPi-Dashboard
# Version to use
# - Stable = Use release version of DietPi-Dashboard.
# - Nightly = Use unstable version DietPi-Dashboard. Might have bugs, but will probably have more features.
SOFTWARE_DIETPI_DASHBOARD_VERSION=Stable
# Whether to only install backend or not
SOFTWARE_DIETPI_DASHBOARD_BACKEND=0

#------------------------------------------------------------------------------------------------------
##### Dev settings #####
#------------------------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit d3003af

Please sign in to comment.