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

feat: add sonar by default to image #107

Merged
merged 1 commit into from
May 19, 2022
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
2 changes: 1 addition & 1 deletion src/config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
export DIST_NAME=MainsailOS
export DIST_VERSION=0.6.1
export BASE_IMAGE_ENLARGEROOT=2500
export MODULES="base,pkgupgrade,mainsailos(network,piconfig,klipper,is_req_preinstall,moonraker,mainsail,mjpgstreamer,serialcomm,password-for-sudo)"
export MODULES="base,pkgupgrade,mainsailos(network,piconfig,klipper,is_req_preinstall,moonraker,mainsail,mjpgstreamer,sonar,password-for-sudo)"
export BASE_RELEASE_COMPRESS=yes
export BASE_IMAGE_RESIZEROOT=600
18 changes: 18 additions & 0 deletions src/modules/sonar/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
#### Sonar - A WiFi Keepalive daemon
####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2022
#### https://github.com/mainsail-crew/sonar
####
#### This File is distributed under GPLv3
####
# shellcheck disable=all

# Sonar
[ -n "$SONAR_SONAR_REPO_SHIP" ] || SONAR_SONAR_REPO_SHIP=https://github.com/mainsail-crew/sonar.git
[ -n "$SONAR_SONAR_REPO_BRANCH" ] || SONAR_SONAR_REPO_BRANCH=main
[ -n "$SONAR_SONAR_DEPS" ] || SONAR_SONAR_DEPS="git crudini iputils-ping"
[ -n "$SONAR_SONAR_DEFAULT_CONF" ] || SONAR_SONAR_DEFAULT_CONF="mainsail_default.conf"
# Add Sonar to moonraker.conf (update manager) bool (1:yes / 0:no)
[ -n "$SONAR_SONAR_ADD_SONAR_MOONRAKER" ] || SONAR_SONAR_ADD_SONAR_MOONRAKER=1
51 changes: 51 additions & 0 deletions src/modules/sonar/start_chroot_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
#### Sonar - A WiFi Keepalive daemon
####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2022
#### https://github.com/mainsail-crew/sonar
####
#### This File is distributed under GPLv3
####

# # shellcheck enable=require-variable-braces

# Error handling
set -ex

source /common.sh
install_cleanup_trap

echo_green "Installing sonar and enable sonar Service ..."
# install dependencies
# force apt update
apt update
check_install_pkgs "${SONAR_SONAR_DEPS}"
# Move to $HOME dir
pushd /home/"${BASE_USER}" &> /dev/null || exit 1
# clone Repo
echo_green "Clone sonar repository ..."
gitclone SONAR_SONAR_REPO sonar
# install sonar
pushd /home/"${BASE_USER}"/sonar &> /dev/null || exit 1
echo_green "Running sonar installer ..."
if [ "${SONAR_SONAR_ADD_MOONRAKER}" == "1" ]; then
sudo -u "${BASE_USER}" \
make unattended
else
sudo -u "${BASE_USER}" \
make install
fi
if [ ! -d "/home/${BASE_USER}/klipper_config" ]; then
mkdir -p "/home/${BASE_USER}/klipper_config"
fi
echo_green "Copying default config file ..."
sudo -u "${BASE_USER}" \
cp "${PWD}/sample_config/${SONAR_SONAR_DEFAULT_CONF}" \
"/home/${BASE_USER}/klipper_config/sonar.conf"
popd &> /dev/null || exit 1

# enable systemd service
systemctl_if_exists enable sonar.service

popd &> /dev/null || exit 1