mirror of
https://github.com/m8tin/cis.git
synced 2026-06-02 14:56:58 +02:00
Using base.module.sh, replaced basename and dirname
This commit is contained in:
@@ -34,7 +34,7 @@ function allChecks() {
|
|||||||
! [ -x "${_CURRENT_CHECK}" ] \
|
! [ -x "${_CURRENT_CHECK}" ] \
|
||||||
&& continue
|
&& continue
|
||||||
_CHECK_FOUND="true"
|
_CHECK_FOUND="true"
|
||||||
_NAME="$(basename ${_CURRENT_CHECK} | cut -d'.' -f1)"
|
_NAME="$(echo ${_CURRENT_CHECK##*/} | cut -d'.' -f1)"
|
||||||
_CONTEXT="$(echo ${_NAME} | cut -d'_' -f1)"
|
_CONTEXT="$(echo ${_NAME} | cut -d'_' -f1)"
|
||||||
_CHECK="$(echo ${_NAME} | cut -d'_' -f2- | tr '_' ' ')"
|
_CHECK="$(echo ${_NAME} | cut -d'_' -f2- | tr '_' ' ')"
|
||||||
_RESULT="$("${_CURRENT_CHECK}" && echo OK || echo FAIL)"
|
_RESULT="$("${_CURRENT_CHECK}" && echo OK || echo FAIL)"
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
source /cis/core/base.module.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
local _SCRIPTPATH _DH_PATH _SELF_SIGNED_PATH
|
local _DH_PATH _SELF_SIGNED_PATH
|
||||||
_SCRIPTPATH="$(cd -- "$(dirname "$0")" > /dev/null 2>&1; pwd -P)"
|
|
||||||
_DH_PATH="/etc/ssl/private"
|
_DH_PATH="/etc/ssl/private"
|
||||||
_SELF_SIGNED_PATH="/etc/ssl/private"
|
_SELF_SIGNED_PATH="/etc/ssl/private"
|
||||||
readonly _SCRIPTPATH _DH_PATH _SELF_SIGNED_PATH
|
readonly _DH_PATH _SELF_SIGNED_PATH
|
||||||
|
|
||||||
! dpkg -s nginx > /dev/null 2>&1 \
|
! dpkg -s nginx > /dev/null 2>&1 \
|
||||||
&& apt-get --yes install nginx-full \
|
&& apt-get --yes install nginx-full \
|
||||||
@@ -35,9 +37,9 @@ function main() {
|
|||||||
|
|
||||||
#TODO Links erstellen
|
#TODO Links erstellen
|
||||||
# [ -d "/etc/nginx/" ] \
|
# [ -d "/etc/nginx/" ] \
|
||||||
# && cp "${_SCRIPTPATH}/etc_nginx_conf.d/"* "/etc/nginx/conf.d/" \
|
# && cp "${CIS[SCRIPTDIR]:?"Missing global SCRIPTDIR"}/etc_nginx_conf.d/"* "/etc/nginx/conf.d/" \
|
||||||
# && mkdir -p /etc/nginx/ssl-trusted \
|
# && mkdir -p /etc/nginx/ssl-trusted \
|
||||||
# && cp "${_SCRIPTPATH}/etc_nginx_ssl-trusted/"* "/etc/nginx/ssl-trusted/" \
|
# && cp "${CIS[SCRIPTDIR]:?"Missing global SCRIPTDIR"}/etc_nginx_ssl-trusted/"* "/etc/nginx/ssl-trusted/" \
|
||||||
# && mkdir -p /var/www/letsencrypt/.well-known/acme-challenge \
|
# && mkdir -p /var/www/letsencrypt/.well-known/acme-challenge \
|
||||||
# && echo "Basis-Konfiguration erfolgreich erstellt." \
|
# && echo "Basis-Konfiguration erfolgreich erstellt." \
|
||||||
# || echo "Basis-Konfiguration bereits vorhanden."
|
# || echo "Basis-Konfiguration bereits vorhanden."
|
||||||
@@ -51,4 +53,4 @@ function main() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@" && exit 0 || exit 1
|
main && exit 0 || exit 1
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
source /cis/base/base.module.sh
|
||||||
|
|
||||||
#WARNING: Used for core functionality in setup.sh
|
#WARNING: Used for core functionality in setup.sh
|
||||||
# DO NOT rename the script and test changes well!
|
# DO NOT rename the script and test changes well!
|
||||||
|
|
||||||
_SCRIPT_FOLDER="$(dirname $(readlink -f "${0}" 2> /dev/null) 2> /dev/null)"
|
source "${CIS[COREROOT]:?"Missing global COREROOT"}addNormalUser.sh" "${1:?"Missing first parameter USER"}" && exit 0 || exit 1
|
||||||
_ROOT="${_SCRIPT_FOLDER%%/script/*}/" #Removes longest matching pattern '/script/*' from the end
|
|
||||||
source "${_ROOT:?"Missing ROOT"}core/addNormalUser.sh" "${1:?"Missing first parameter USER"}" && exit 0 || exit 1
|
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ function addSessions() {
|
|||||||
local _COMPOSITION
|
local _COMPOSITION
|
||||||
grep -lrE "^${_RECEIVERHOST}" ${_DEFINITIONS}compositions/*/${_SYNCHOSTS_FILE} | while read -r _CURRENT_SYNCHOSTS_FILE; do
|
grep -lrE "^${_RECEIVERHOST}" ${_DEFINITIONS}compositions/*/${_SYNCHOSTS_FILE} | while read -r _CURRENT_SYNCHOSTS_FILE; do
|
||||||
_SSH_PORT=$(grep -E "^${_RECEIVERHOST} usePort [0-9]*.*$" "${_CURRENT_SYNCHOSTS_FILE}" | cut -d' ' -f3 | xargs)
|
_SSH_PORT=$(grep -E "^${_RECEIVERHOST} usePort [0-9]*.*$" "${_CURRENT_SYNCHOSTS_FILE}" | cut -d' ' -f3 | xargs)
|
||||||
_COMPOSITION=$(basename $(dirname "${_CURRENT_SYNCHOSTS_FILE}"))
|
_COMPOSITION="${_CURRENT_SYNCHOSTS_FILE%/*}"
|
||||||
|
_COMPOSITION="${_COMPOSITION##*/}"
|
||||||
startMissingScreenSession "${_COMPOSITION}" "${_SSH_PORT}"
|
startMissingScreenSession "${_COMPOSITION}" "${_SSH_PORT}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source /cis/core/base.module.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function listSnapshotsToDestroy() {
|
||||||
|
local _FILESYSTEM _SNAPSHOT
|
||||||
|
_SNAPSHOT="${1:?"Missing first parameter SNAPSHOT"}"
|
||||||
|
_FILESYSTEM="$(echo ${_SNAPSHOT} | cut -d@ -f1)"
|
||||||
|
readonly _FILESYSTEM _SNAPSHOT
|
||||||
|
|
||||||
|
for _CURRENT in $(zfs list -Ho name -s creation -t snapshot "${_FILESYSTEM:?"Missing first parameter FILESYSTEM"}")
|
||||||
|
do
|
||||||
|
[ -z "${_CURRENT}" ] \
|
||||||
|
&& return 1
|
||||||
|
|
||||||
|
[ "${_SNAPSHOT}" == "${_CURRENT}" ] \
|
||||||
|
&& break
|
||||||
|
|
||||||
|
echo "${_CURRENT}"
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
local _SNAPSHOT
|
||||||
|
_SNAPSHOT="${1:?"Missing first parameter SNAPSHOT"}"
|
||||||
|
readonly _SNAPSHOT
|
||||||
|
|
||||||
|
! echo "${_SNAPSHOT}" | grep -q "@" \
|
||||||
|
&& echo "This is not a snapshot: ${_SNAPSHOT}" \
|
||||||
|
&& return 1
|
||||||
|
|
||||||
|
! zfs list "${_SNAPSHOT}" &> /dev/null \
|
||||||
|
&& echo "The snapshot does not exist: ${_SNAPSHOT}" \
|
||||||
|
&& return 1
|
||||||
|
|
||||||
|
listSnapshotsToDestroy "${_SNAPSHOT}" | xargs -r -p -n1 zfs destroy \
|
||||||
|
&& return 0
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
base.set SNAPSHOT "${1}" '^[-0-9a-zA-Z_/]@[-0-9a-zA-Z_:.]'
|
||||||
|
main "${SNAPSHOT:?"Missing first parameter SNAPSHOT"}" && exit 0
|
||||||
|
|
||||||
|
echo "Something went wrong."
|
||||||
|
exit 1
|
||||||
|
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# trim all mounted or at least root file systems which support it
|
||||||
|
# call this file with cron
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function run(){
|
||||||
|
local _FSTRIM _MAJOR_VERSION _START
|
||||||
|
_MAJOR_VERSION="$(lsb_release -r | cut -f2 | cut -d'.' -f1)"
|
||||||
|
|
||||||
|
[ "${_MAJOR_VERSION:?"Missing MAJOR_VERSION"}" -ge "16" ] \
|
||||||
|
&& _FSTRIM="fstrim -v --all" \
|
||||||
|
|| _FSTRIM="fstrim -v /"
|
||||||
|
|
||||||
|
_START="${SECONDS}"
|
||||||
|
readonly _FSTRIM _MAJOR_VERSION _START
|
||||||
|
|
||||||
|
echo -e "$(date) - fstrim started: '$($_FSTRIM)' (duration: $(date -u -d @"$((${SECONDS} - $_START))" +'%-Hh %Mm %Ss'))"
|
||||||
|
}
|
||||||
|
|
||||||
|
run > /var/log/fstrim.log
|
||||||
Reference in New Issue
Block a user