Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1663

Přidáno uživatelem Ondřej Fibich před asi 12 roky(ů)

Vydani:\n\n- freenetis-ssh-keys 0.2.0\n\nNovinky:\n\n- Skript a konfigurak pro nacitani SSH klicu z FreenetISu\n- Balik freenetis-ssh-keys

Zobrazit rozdíly:

freenetis/branches/testing/application/vendors/ssh-keys/freenetis-ssh-keys-sync.sh
#!/bin/bash
################################################################################
# #
# Author: Michal Kliment, Ondrej Fibich #
# Description: This script updates public SSH keys of admins of the device #
# given by his freenetIS ID. #
# #
# Version: 0.2.0 #
# #
################################################################################
CONFIG=/etc/freenetis/freenetis-ssh-keys.conf
# Load variables
if [ -e $CONFIG ]; then
. $CONFIG || true
TMPFILE="/tmp/"$AUTHORIZED_KEYS
else
echo "`date -R` Config file is missing at path $CONFIG. Terminating..."
exit 0
fi
# check config
if [[ ! "$DEVICE_ID" =~ ^[0-9]+$ ]] || [ $DEVICE_ID -lt 1 ]; then
echo "[ERROR] `date -R` Wrong configuration (ID not set properly)"
exit 1
fi
# SSH config folder
mkdir -p "$HOME/.ssh/"
chmod 0700 "$HOME/.ssh/"
# download
rm -f "$TMPFILE"
echo "[INFO] `date -R` Downloading public SSH keys from (${PATH_FN})"
status=`wget --no-check-certificate --server-response -q "$FULL_PATH" -O "$TMPFILE" 2>&1 | awk '/^ HTTP/{print $2}'`
# check download
if [ "$status" = "200" ]; then
# change keys
if [ $(cat "$TMPFILE" 2> /dev/null | wc -l) -gt 2 ]; then
echo "[INFO] `date -R` Downloaded (code: $status)"
echo "[INFO] `date -R` Backuping old keys to $HOME/.ssh/$AUTHORIZED_KEYS.old"
mv -f "$HOME/.ssh/$AUTHORIZED_KEYS" "$HOME/.ssh/$AUTHORIZED_KEYS.old"
echo "[INFO] `date -R` Loading bew keys to $HOME/.ssh/$AUTHORIZED_KEYS..."
mv -f "$TMPFILE" "$HOME/.ssh/$AUTHORIZED_KEYS"
else
echo "[ERROR] `date -R` Empty response body -> keeping old configuration"
fi
else
echo "[ERROR] `date -R` Download failed (code: $status)"
fi
freenetis/branches/testing/application/vendors/ssh-keys/freenetis-ssh-keys.conf
################################################################################
# #
# Author: Michal Kliment, Ondrej Fibich #
# Description: This script updates public SSH keys of admins of the device #
# given by his freenetIS ID. #
# #
################################################################################
# Base PATH_FN to running FreenetIS instance
PATH_FN=http://localhost/freenetis
# ID of device from FreenetIS
DEVICE_ID=0
# Log file, change to /dev/null to disable logging
LOG_FILE=/var/log/freenetis-ssh-keys.log
# Filename with authorized keys (commonly authorized_key2 or authorized_keys)
AUTHORIZED_KEYS="authorized_keys2"
# Full path [DO NOT CHANGE THIS VARIABLE!!!]
FULL_PATH=$PATH_FN"/index.php/en/web_interface/authorized_keys/"$DEVICE_ID
freenetis/branches/testing/application/vendors/deb/debianization.sh
exit 1
fi
NAMES=(freenetis freenetis-monitoring freenetis-redirection freenetis-ulogd)
NAMES=(freenetis freenetis-monitoring freenetis-redirection freenetis-ulogd freenetis-ssh-keys)
VERSION=$1
if [ $# -eq 2 ]; then
freenetis/branches/testing/application/controllers/web_interface.php
}
echo "#\n";
echo "# Generated by Freenetis at " . date("Y-m-d H:i:s") . "\n";
echo "# Generated by FreenetIS at " . date("Y-m-d H:i:s") . "\n";
echo "#\n";
foreach ($keys as $key)

Také k dispozici: Unified diff