diff --git a/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-gateway-status.sh b/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-gateway-status.sh index 9db9fe67..05a86176 100755 --- a/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-gateway-status.sh +++ b/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-gateway-status.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ### This file managed by Salt, do not edit by hand! ### get_ip() { curl --interface "$1" -sL ip.envs.net ; } diff --git a/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-manuell_update.sh b/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-manuell_update.sh index 02597147..adc714a7 100755 --- a/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-manuell_update.sh +++ b/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-manuell_update.sh @@ -1,19 +1,25 @@ -#!/bin/sh +#!/usr/bin/env sh +### This file managed by Salt, do not edit by hand! ### +# +# Freifunk - Manuell Server Update +# -REV='T_RELEASE_latest' REPO_URL='https://github.com/Freifunk-Dresden/ffdd-server' +REV='T_RELEASE_latest' INSTALL_DIR='/srv/ffdd-server' -if [ "$(id -u)" -ne 0 ]; then printf 'Please run as root!\n'; exit 1 ; fi +CUSTOM_REPO_URL="$(uci -qX get ffdd.sys.freifunk_repo)" +[ -n "$CUSTOM_REPO_URL" ] && [ "$CUSTOM_REPO_URL" != "$REPO_URL" ] && REPO_URL="$CUSTOM_REPO_URL" -if [ -f /usr/local/sbin/uci ] && [ -f /etc/config/ffdd ]; then - CUSTOM_REPO_URL="$(uci -qX get ffdd.sys.freifunk_repo)" - [ -n "$CUSTOM_REPO_URL" ] && [ "$CUSTOM_REPO_URL" != "$REPO_URL" ] && REPO_URL="$CUSTOM_REPO_URL" +CUSTOM_REV="$(uci -qX get ffdd.sys.branch)" +[ -n "$CUSTOM_REV" ] && [ "$CUSTOM_REV" != "$REV" ] && REV="$CUSTOM_REV" - CUSTOM_REV="$(uci -qX get ffdd.sys.branch)" - [ -n "$CUSTOM_REV" ] && [ "$CUSTOM_REV" != "$REV" ] && REV="$CUSTOM_REV" -fi +CUSTOM_INSTALL_DIR="$(uci -qX get ffdd.sys.install_dir)" +[ -n "$CUSTOM_INSTALL_DIR" ] && [ "$CUSTOM_INSTALL_DIR" != "$INSTALL_DIR" ] && INSTALL_DIR="$CUSTOM_INSTALL_DIR" + + +if [ "$(id -u)" -ne 0 ]; then printf 'Please run as root!\n'; exit 1 ; fi [ -d "$INSTALL_DIR" ] && rm -rf "$INSTALL_DIR" git clone "$REPO_URL" "$INSTALL_DIR" diff --git a/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-uci_autosetup.sh b/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-uci_autosetup.sh index f6013a76..bbc573e1 100755 --- a/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-uci_autosetup.sh +++ b/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-uci_autosetup.sh @@ -1,17 +1,13 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ### This file managed by Salt, do not edit by hand! ### # # Freifunk - Autosetup for /etc/config/ffdd # export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -# -# Get variables from /etc/config/ffdd -ddmesh_node="$(uci -qX get ffdd.sys.ddmesh_node)" ddmesh_key="$(uci -qX get ffdd.sys.ddmesh_registerkey)" if [ -z "$ddmesh_key" ] || [ "$ddmesh_key" = '-' ]; then - # set ddmesh_registerkey ddmesh_key="$(ip link | sha256sum | sed 's#\(..\)#\1:#g;s#[ :-]*$##')" uci set ffdd.sys.ddmesh_registerkey="$ddmesh_key" @@ -24,5 +20,4 @@ if [ -z "$ddmesh_key" ] || [ "$ddmesh_key" = '-' ]; then uci commit fi -# exit 0 diff --git a/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-version b/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-version index 5f07e996..583b3723 100755 --- a/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-version +++ b/salt/freifunk/base/ddmesh/usr/local/bin/freifunk-version @@ -1,11 +1,18 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh +### This file managed by Salt, do not edit by hand! ### +# +# Freifunk - Server Version Info +# -install_dir="$(uci -qX get ffdd.sys.install_dir)" -version="$(head -n3 "$install_dir"/init_server.sh | grep -oP '(?<=^#version=).+' | tr -d '"')" -rev="$(git --git-dir="$install_dir"/.git describe --all --abbrev=0 | cut -f2 -d"/")" -commit="$(git --git-dir="$install_dir"/.git show --oneline -s | awk '{print $1}')" +INSTALL_DIR='/srv/ffdd-server' -if [ "$install_dir" != '' ]; then +CUSTOM_INSTALL_DIR="$(uci -qX get ffdd.sys.install_dir)" +[ -n "$CUSTOM_INSTALL_DIR" ] && [ "$CUSTOM_INSTALL_DIR" != "$INSTALL_DIR" ] && INSTALL_DIR="$CUSTOM_INSTALL_DIR" + +if [ -d "$INSTALL_DIR" ]; then + version="$(head -n3 "$INSTALL_DIR"/init_server.sh | grep -oP '(?<=^#version=).+' | tr -d '"')" + rev="$(git --git-dir="$INSTALL_DIR"/.git describe --all --abbrev=0 | cut -f2 -d"/")" + commit="$(git --git-dir="$INSTALL_DIR"/.git show --oneline -s | awk '{print $1}')" printf '%s - %s (%s)\n' "$version" "$rev" "$commit" else printf 'n.a.\n'