Initial status

This commit is contained in:
Crashillo 2020-05-02 10:52:40 +02:00
commit 8f816cf9b9
26 changed files with 2269 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.conf
img/*
logs/*
!*/.gitkeep

14
bin/INSTALL Normal file
View File

@ -0,0 +1,14 @@
#!/bin/bash
# Run this file: sudo install-scripts [script1] [script2] ...
# That will be create a copy of the arguments passed into a execution-granted folder
source commons
ensure_root && ensure_args $@
for arg in $*
do
cp -uv $PWD/$arg /usr/local/bin && chmod 655 /usr/local/bin/$arg
done
exit 0

View File

@ -0,0 +1,55 @@
#!/bin/bash
usage() {
echo "Usage ./$0 [-a] [-o] [-p]"
echo
echo "-a Run only in acer machine"
echo "-o Run only in osmc machine"
echo "-p Run only in pi machine"
echo
echo "Default: Run in all machines"
}
# defaults
ACER=0
OSMC=0
PI=0
while getopts ":aoph" opt;
do
case $opt in
a) ((ACER++));((OSMC--));((PI--));;
o) ((ACER--));((OSMC++));((PI--));;
p) ((ACER--));((OSMC--));((PI++));;
*) echo "No";;
h) usage;;
esac
done
shift $((OPTIND -1))
DIR=/mnt/nfs/HDD/.backup/bin
# Use the rest of arguments
COMMAND="cd $DIR; sudo ./install-scripts $@"
# Caso extremo en el que se dan todas las banderas explicitamente -a -o -p
if [ $ACER -eq -1 ] && [ $OSMC -eq -1 ] && [ $PI -eq -1 ]
then
((ACER++));((OSMC++));((PI++));
fi
if [ $ACER -ge 0 ]
then
ssh -t hugo@acer $COMMAND;
fi
if [ $OSMC -ge 0 ]
then
ssh -t osmc@osmc $COMMAND;
fi
if [ $PI -ge 0 ]
then
ssh -t pi@pi $COMMAND;
fi
exit 0

View File

@ -0,0 +1,31 @@
#!/bin/bash
# Configuration
LOG_FILE=${1:-"$MOUNTPATH/.backup/logs/transmission-postprocess.log"}
# Input Parameters
OPT_PATH="$TR_TORRENT_DIR/$TR_TORRENT_NAME"
OPT_NAME="$TR_TORRENT_NAME"
OPT_LABEL="N/A"
# Formatting options
MOVIES="$MOUNTPATH/media/Movies/{n} ({y})/{n.upperInitial().space(\".\")}{\".CD\"+pi}.{y}{\".\"+vc}{\".\"+vf}{\".\"+ac}{\".\"+source}{\"-\"+group}{\".\"+lang.getLocale()}"
SERIES="$MOUNTPATH/media/Series/{n}/Season {s.pad(2)}/{n.space(\".\")}.{sxe}.{t.space(\".\")}{\".\"+source}{\".\"+vc}{\"-\"+group}{\".\"+lang.getLocale()}"
# Build command
COMMAND="filebot -script fn:amc --output '$TR_TORRENT_DIR' --action move --conflict skip --lang es -non-strict --def unsorted=y music=y clean=y kodi=osmc ut_dir='$OPT_PATH' ut_kind=multi ut_title='$OPT_NAME' ut_label='$OPT_LABEL' seriesFormat='$SERIES' movieFormat='$MOVIES'"
COMMAND="$COMMAND | ts"
# Log
(echo;echo $COMMAND;echo;) >> $LOG_FILE 2>&1
# Run locally and in background
#COMMAND="export JAVA_OPTS=\"-Xmx256m\"; $COMMAND"
#eval $COMMAND >> $LOG_FILE 2>&1 &
# Run remotely
echo $COMMAND | ssh hugo@acer "sh -s" >> $LOG_FILE 2>&1
#RESULT=$?
# No eliminar torrent
exit 0;

33
bin/backup Normal file
View File

@ -0,0 +1,33 @@
#!/bin/bash
source commons
HOST=$(hostname)
DIR=$MOUNTPATH/config/img
FILE=$DIR/$HOST.img
LOG=$MOUNTPATH/config/logs/$(basename $0).$HOST.log
START=$(date +%s)
# Run backup to a temporary file
dd if=/dev/mmcblk0 of=$FILE.tmp conv=noerror,sync bs=16k status=none 2> $LOG
# Rename file once finished
mv $FILE.tmp $FILE
END=$(date +%s)
RUNTIME=$(humantime $(expr $END - $START))
MESSAGE=$(cat <<EOF
Finalizó la backup de \`$HOST\`.
Ha tardado: $RUNTIME
Output:
$(tail -3 $LOG)
EOF
)
echo >> $LOG
echo "$MESSAGE" | xargs -0 telegram-bot
exit 0

73
bin/commons Normal file
View File

@ -0,0 +1,73 @@
#!/bin/bash
# variables
export TERM=xterm-256color
export MOUNTPATH=/mnt/nfs/HDD
# alias
alias du='du -hd 1 | sort -h'
alias mkdir='mkdir -pv'
alias pi='ssh pi@pi'
alias pi2='ssh pi@pi2'
alias pi4='ssh root@pi4'
alias rm='rm -I --preserve-root'
alias ..='cd ..'
alias ...='cd ../../'
alias ....='cd ../../../'
alias .....='cd ../../../../'
alias media='cd $MOUNTPATH/media'
alias bin='cd $MOUNTPATH/config/bin'
alias logs='cd $MOUNTPATH/config/logs'
alias diff='diff -yiBW200 --color=always'
# functions
is_root() {
[[ "$EUID" -eq 0 ]]
}
has_args() {
[[ $# -ne 0 ]]
}
ensure_root() {
if ! is_root; then
>&2 echo "Please run as root"
exit 1
fi
}
ensure_args() {
if ! has_args $@; then
>&2 echo "No arguments provided"
exit 1
fi
}
humantime() {
local ARG;
case "$1" in
-l) ARG=$2; LONG=true;;
*) ARG=$1
esac
local T=$ARG
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
if [ "$LONG" = true ]; then
(( $D > 0 )) && printf '%d day%.*s ' $D $(( $D != 1 )) "s"
(( $H > 0 )) && printf '%d hour%.*s ' $H $(( $H != 1 )) "s"
(( $M > 0 )) && printf '%d minute%.*s ' $M $(( $M != 1 )) "s"
(( ($D > 0 || $H > 0 || $M > 0) && $S > 0 )) && printf 'and '
(( $S > 0 )) && printf '%d second%.*s' $S $(( $S != 1 )) "s"
else
(( $D > 0 )) && printf '%dd ' $D
(( $H > 0 )) && printf '%dh ' $H
(( $M > 0 )) && printf '%dmin ' $M
(( $S > 0 )) && printf '%ds' $S
fi
echo
}

90
bin/maintenance Normal file
View File

@ -0,0 +1,90 @@
#!/bin/bash
source commons
HOST=$(hostname)
FILE=$MOUNTPATH/config/logs/$(basename $0).$HOST.log
START=$(date +%s)
# Run uc command
ERR=$( { uc | ts > $FILE; } 2>&1 )
END=$(date +%s)
RUNTIME=$(humantime $(expr $END - $START))
INSTALLS=$(sed -n '/'"`date +%Y-%m-%d`"'/,$p' /var/log/apt/history.log | grep Install | cut -d ' ' -f 2 | cut -d ':' -f 1)
UPGRADES=$(sed -n '/'"`date +%Y-%m-%d`"'/,$p' /var/log/apt/history.log | grep Upgrade | cut -d ' ' -f 2 | cut -d ':' -f 1)
REMOVES=$(sed -n '/'"`date +%Y-%m-%d`"'/,$p' /var/log/apt/history.log | grep Remove | cut -d ' ' -f 2 | cut -d ':' -f 1)
PURGES=$(sed -n '/'"`date +%Y-%m-%d`"'/,$p' /var/log/apt/history.log | grep Purge | cut -d ' ' -f 2 | cut -d ':' -f 1)
MESSAGE=$(cat <<-EOF
La máquina \`$HOST\` se actualizó automáticamente.
Ha tardado: $RUNTIME
\`\`\`
\`\`\`
EOF
)
if [[ ! -z "$INSTALLS" ]]; then
MESSAGE+=$(cat <<-EOF
*Instalados*
\`\`\`
$INSTALLS
\`\`\`
EOF
)
fi
if [[ ! -z "$UPGRADES" ]]; then
MESSAGE+=$(cat <<-EOF
*Actualizados*
\`\`\`
$UPGRADES
\`\`\`
EOF
)
fi
if [[ ! -z "$REMOVES" ]]; then
MESSAGE+=$(cat <<-EOF
*Eliminados*
\`\`\`
$REMOVES
\`\`\`
EOF
)
fi
if [[ ! -z "$PURGES" ]]; then
MESSAGE+=$(cat <<-EOF
*Purgados*
\`\`\`
$PURGES
\`\`\`
EOF
)
fi
if [[ ! -z "$ERR" ]]; then
MESSAGE+=$(cat <<-EOF
*Errores*
\`\`\`
$ERR
\`\`\`
EOF
)
fi
if [[ -z "$ERR" ]] && [[ -z "$INSTALLS" ]] && [[ -z "$UPGRADES" ]] && [[ -z "$REMOVES" ]] && [[ -z "$PURGES" ]]; then
MESSAGE+=$(cat <<-EOF
Nada que actualizar ni que limpiar. :)
EOF
)
fi
echo >> $FILE
echo "$MESSAGE" | xargs -0 telegram-bot
exit 0

339
bin/pishrink Normal file
View File

@ -0,0 +1,339 @@
#!/bin/bash
version="v0.1.2"
CURRENT_DIR=$(pwd)
SCRIPTNAME="${0##*/}"
LOGFILE=${CURRENT_DIR}/${SCRIPTNAME%.*}.log
function info() {
echo "$SCRIPTNAME: $1..."
}
function error() {
echo -n "$SCRIPTNAME: ERROR occured in line $1: "
shift
echo "$@"
}
function cleanup() {
if losetup "$loopback" &>/dev/null; then
losetup -d "$loopback"
fi
if [ "$debug" = true ]; then
local old_owner=$(stat -c %u:%g "$src")
chown "$old_owner" "$LOGFILE"
fi
}
function logVariables() {
if [ "$debug" = true ]; then
echo "Line $1" >> "$LOGFILE"
shift
local v var
for var in "$@"; do
eval "v=\$$var"
echo "$var: $v" >> "$LOGFILE"
done
fi
}
function checkFilesystem() {
info "Checking filesystem"
e2fsck -pf "$loopback"
(( $? < 4 )) && return
info "Filesystem error detected!"
info "Trying to recover corrupted filesystem"
e2fsck -y "$loopback"
(( $? < 4 )) && return
if [[ $repair == true ]]; then
info "Trying to recover corrupted filesystem - Phase 2"
e2fsck -fy -b 32768 "$loopback"
(( $? < 4 )) && return
fi
error $LINENO "Filesystem recoveries failed. Giving up..."
exit -9
}
help() {
local help
read -r -d '' help << EOM
Usage: $0 [-sdrpzh] imagefile.img [newimagefile.img]
-s: Don't expand filesystem when image is booted the first time
-d: Write debug messages in a debug log file
-r: Use advanced filesystem repair option if the normal one fails
-p: Remove logs, apt archives, dhcp leases and ssh hostkeys
-z: Gzip compress image after shrinking
EOM
echo "$help"
exit -1
}
usage() {
echo "Usage: $0 [-sdrpzh] imagefile.img [newimagefile.img]"
echo ""
echo " -s: Skip autoexpand"
echo " -d: Debug mode on"
echo " -r: Use advanced repair options"
echo " -p: Remove logs, apt archives, dhcp leases and ssh hostkeys"
echo " -z: Gzip compress image after shrinking"
echo " -h: display help text"
exit -1
}
should_skip_autoexpand=false
debug=false
repair=false
gzip_compress=false
prep=false
while getopts ":sdrpzh" opt; do
case "${opt}" in
s) should_skip_autoexpand=true ;;
d) debug=true;;
r) repair=true;;
p) prep=true;;
z) gzip_compress=true;;
h) help;;
*) usage ;;
esac
done
shift $((OPTIND-1))
if [ "$debug" = true ]; then
info "Creating log file $LOGFILE"
rm "$LOGFILE" &>/dev/null
exec 1> >(stdbuf -i0 -o0 -e0 tee -a "$LOGFILE" >&1)
exec 2> >(stdbuf -i0 -o0 -e0 tee -a "$LOGFILE" >&2)
fi
echo "${0##*/} $version"
#Args
src="$1"
img="$1"
#Usage checks
if [[ -z "$img" ]]; then
usage
fi
if [[ ! -f "$img" ]]; then
error $LINENO "$img is not a file..."
exit -2
fi
if (( EUID != 0 )); then
error $LINENO "You need to be running as root."
exit -3
fi
#Check that what we need is installed
for command in parted losetup tune2fs md5sum e2fsck resize2fs; do
command -v $command >/dev/null 2>&1
if (( $? != 0 )); then
error $LINENO "$command is not installed."
exit -4
fi
done
#Copy to new file if requested
if [ -n "$2" ]; then
info "Copying $1 to $2..."
cp --reflink=auto --sparse=always "$1" "$2"
if (( $? != 0 )); then
error $LINENO "Could not copy file..."
exit -5
fi
old_owner=$(stat -c %u:%g "$1")
chown "$old_owner" "$2"
img="$2"
fi
# cleanup at script exit
trap cleanup ERR EXIT
#Gather info
info "Gathering data"
beforesize=$(ls -lh "$img" | cut -d ' ' -f 5)
parted_output=$(parted -ms "$img" unit B print | tail -n 1)
partnum=$(echo "$parted_output" | cut -d ':' -f 1)
partstart=$(echo "$parted_output" | cut -d ':' -f 2 | tr -d 'B')
loopback=$(losetup -f --show -o "$partstart" "$img")
tune2fs_output=$(tune2fs -l "$loopback")
currentsize=$(echo "$tune2fs_output" | grep '^Block count:' | tr -d ' ' | cut -d ':' -f 2)
blocksize=$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':' -f 2)
logVariables $LINENO tune2fs_output currentsize blocksize
#Check if we should make pi expand rootfs on next boot
if [ "$should_skip_autoexpand" = false ]; then
#Make pi expand rootfs on next boot
mountdir=$(mktemp -d)
mount "$loopback" "$mountdir"
if [ "$(md5sum "$mountdir/etc/rc.local" | cut -d ' ' -f 1)" != "0542054e9ff2d2e0507ea1ffe7d4fc87" ]; then
echo "Creating new /etc/rc.local"
mv "$mountdir/etc/rc.local" "$mountdir/etc/rc.local.bak"
#####Do not touch the following lines#####
cat <<\EOF1 > "$mountdir/etc/rc.local"
#!/bin/bash
do_expand_rootfs() {
ROOT_PART=$(mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p')
PART_NUM=${ROOT_PART#mmcblk0p}
if [ "$PART_NUM" = "$ROOT_PART" ]; then
echo "$ROOT_PART is not an SD card. Don't know how to expand"
return 0
fi
# Get the starting offset of the root partition
PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d: | sed 's/[^0-9]//g')
[ "$PART_START" ] || return 1
# Return value will likely be error for fdisk as it fails to reload the
# partition table because the root fs is mounted
fdisk /dev/mmcblk0 <<EOF
p
d
$PART_NUM
n
p
$PART_NUM
$PART_START
p
w
EOF
cat <<EOF > /etc/rc.local &&
#!/bin/sh
echo "Expanding /dev/$ROOT_PART"
resize2fs /dev/$ROOT_PART
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
EOF
reboot
exit
}
raspi_config_expand() {
/usr/bin/env raspi-config --expand-rootfs
if [[ $? != 0 ]]; then
return -1
else
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
reboot
exit
fi
}
raspi_config_expand
echo "WARNING: Using backup expand..."
sleep 5
do_expand_rootfs
echo "ERROR: Expanding failed..."
sleep 5
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
exit 0
EOF1
#####End no touch zone#####
chmod +x "$mountdir/etc/rc.local"
fi
umount "$mountdir"
else
echo "Skipping autoexpanding process..."
fi
if [[ $prep == true ]]; then
info "Syspreping: Removing logs, apt archives, dhcp leases and ssh hostkeys"
mountdir=$(mktemp -d)
mount "$loopback" "$mountdir"
rm -rf "$mountdir/var/cache/apt/archives/*" "$mountdir/var/lib/dhcpcd5/*" "$mountdir/var/log/*" "$mountdir/var/tmp/*" "$mountdir/tmp/*" "$mountdir/etc/ssh/*_host_*"
umount "$mountdir"
fi
#Make sure filesystem is ok
checkFilesystem
if ! minsize=$(resize2fs -P "$loopback"); then
rc=$?
error $LINENO "resize2fs failed with rc $rc"
exit -10
fi
minsize=$(cut -d ':' -f 2 <<< "$minsize" | tr -d ' ')
logVariables $LINENO minsize
if [[ $currentsize -eq $minsize ]]; then
error $LINENO "Image already shrunk to smallest size"
exit -11
fi
#Add some free space to the end of the filesystem
extra_space=$(($currentsize - $minsize))
logVariables $LINENO extra_space
for space in 5000 1000 100; do
if [[ $extra_space -gt $space ]]; then
minsize=$(($minsize + $space))
break
fi
done
logVariables $LINENO minsize
#Shrink filesystem
info "Shrinking filesystem"
resize2fs -p "$loopback" $minsize
if [[ $? != 0 ]]; then
error $LINENO "resize2fs failed"
mount "$loopback" "$mountdir"
mv "$mountdir/etc/rc.local.bak" "$mountdir/etc/rc.local"
umount "$mountdir"
losetup -d "$loopback"
exit -12
fi
sleep 1
#Shrink partition
partnewsize=$(($minsize * $blocksize))
newpartend=$(($partstart + $partnewsize))
logVariables $LINENO partnewsize newpartend
if ! parted -s -a minimal "$img" rm "$partnum"; then
rc=$?
error $LINENO "parted failed with rc $rc"
exit -13
fi
if ! parted -s "$img" unit B mkpart primary "$partstart" "$newpartend"; then
rc=$?
error $LINENO "parted failed with rc $rc"
exit -14
fi
#Truncate the file
info "Shrinking image"
if ! endresult=$(parted -ms "$img" unit B print free); then
rc=$?
error $LINENO "parted failed with rc $rc"
exit -15
fi
endresult=$(tail -1 <<< "$endresult" | cut -d ':' -f 2 | tr -d 'B')
logVariables $LINENO endresult
if ! truncate -s "$endresult" "$img"; then
rc=$?
error $LINENO "trunate failed with rc $rc"
exit -16
fi
if [[ $gzip_compress == true ]]; then
info "Gzipping the shrunk image"
if [[ ! $(gzip -f9 "$img") ]]; then
img=$img.gz
fi
fi
aftersize=$(ls -lh "$img" | cut -d ' ' -f 5)
logVariables $LINENO aftersize
info "Shrunk $img from $beforesize to $aftersize"

31
bin/ppa Normal file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env bash
for f in /etc/apt/sources.list.d/*.list; do
grep -Po "(?<=^deb\s).*?(?=#|$)" "$f" | while read -r ENTRY ; do
echo "ENTRY: $ENTRY"
HOST=$(cut -d/ -f3 <<< "$ENTRY")
if [ "ppa.launchpad.net" = "$HOST" ]; then
USER=$(cut -d/ -f4 <<< "$ENTRY")
PPA=$(cut -d/ -f5 <<< "$ENTRY")
packageCount=$(awk '$1=="Package:" {if (a[$2]++ == 0) {system("dpkg -l "$2)}}' /var/lib/apt/lists/*"$USER"*"$PPA"*Packages 2>/dev/null | awk '/^ii/' | wc -l)
echo "PPA: ppa:$USER/$PPA"
echo "FILENAME: $f"
echo "$packageCount package(s) installed"
if [ "$packageCount" -eq 0 ] && [ "$1" == "--delete" ]; then
sudo rm "$f" && echo "$f deleted"
fi
echo
else
USER=$(cut -d/ -f3 <<< "$ENTRY")
PPA=$(cut -d/ -f4 <<< "$ENTRY")
packageCount=$(awk '$1=="Package:" {if (a[$2]++ == 0) {system("dpkg -l "$2)}}' /var/lib/apt/lists/*"$USER"*Packages 2>/dev/null | awk '/^ii/' | wc -l)
echo "REPOSITORY: $USER/$PPA"
echo "FILENAME: $f"
echo "$packageCount package(s) installed"
if [ "$packageCount" -eq 0 ] && [ "$1" == "--delete" ]; then
sudo rm "$f" && echo "$f deleted"
fi
echo
fi
done
done

11
bin/pw Normal file
View File

@ -0,0 +1,11 @@
#!/bin/bash
while getopts e:d: o
do case "$o" in
e) echo -n $OPTARG | openssl enc -des3 -k mysalt | openssl enc -base64;;
d) echo $OPTARG | openssl enc -base64 -d | openssl enc -des3 -k mysalt -d;echo;;
[?]) echo >&2 "Usage: $0 [-e <human-readable text>] [-d <encrypted text>]"
exit 1;;
esac
done
exit 0;

29
bin/shrink Normal file
View File

@ -0,0 +1,29 @@
#!/bin/bash
source commons
ensure_root && ensure_args $@
HOST=$(hostname)
NAME=$(basename $1 .img)
FILE=$MOUNTPATH/config/logs/$(basename $0).$NAME.log
START=$(date +%s)
pishrink $1 | ts >> $FILE 2>&1
END=$(date +%s)
RUNTIME=$(humantime $(expr $END - $START))
MESSAGE=$(cat <<EOF
Se ha encogido el fichero \`$(basename $1)\`
Ha tardado: $RUNTIME
Previsualización del log:
$(tail -2 $FILE)
EOF
)
echo >> $FILE
echo "$MESSAGE" | xargs -0 telegram-bot
exit 0

1430
bin/speedtest Normal file

File diff suppressed because it is too large Load Diff

10
bin/telegram-bot Normal file
View File

@ -0,0 +1,10 @@
#!/bin/bash
TOKEN="971389171:AAHBi-OjTUQs5SR1j3BuoWs-mVdPb0E3reg"
USER="45714853"
URL="https://api.telegram.org/bot$TOKEN/sendMessage"
MESSAGE=$1
curl -s -X POST $URL -d chat_id="$USER" -d text="$MESSAGE" -d parse_mode="markdown" > /dev/null
exit 0;

57
bin/uc Normal file
View File

@ -0,0 +1,57 @@
#!/bin/bash
source commons
ensure_root
echo "## Script de actualización y limpieza ##";
# Update
echo; echo "-- apt-get update --"
apt-get update
OS=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
# Upgrade (OSMC special treatment)
if [[ $OS == *"OSMC"* ]]; then
echo; echo "-- apt-get full-upgrade -y -q --"
apt-get full-upgrade -y -q
else
echo; echo "-- apt-get upgrade -y -q --"
apt-get upgrade -y -q
fi
# Distinguish Ubuntu/Debian, then dist-upgrade
if [[ $OS == *"Ubuntu"* ]]; then
echo; echo "-- apt-get dist-upgrade -y -q --"
apt-get dist-upgrade -y -q
fi
# Install deborphan and run clean-ups
if [[ `dpkg -l | grep -i deborphan | head -1 | cut -d ' ' -f 1` != "ii" ]]; then
echo; echo "Package deborphan no installed. Installing..."
apt-get install deborphan -y -q
echo "Done!"
fi
echo; echo "-- deborphan | xargs sudo apt-get -y -q remove --purge --"
deborphan | xargs sudo apt-get -y -q remove --purge
echo; echo "-- deborphan --guess-data | xargs sudo apt-get -y -q remove --purge --"
deborphan --guess-data | xargs apt-get -y -q remove --purge
echo; echo "-- apt-get -y -q purge 'deborphan --guess-data' --"
apt-get -y -q purge `deborphan --guess-data`
# Autoremove
echo; echo "-- apt-get autoremove -y -q --"
apt-get autoremove -y -q
# Autoclean
echo; echo "-- apt-get autoclean --"
apt-get autoclean
#Remove broken and residual packages
echo; echo "-- apt-get -y -q remove --purge \$(dpkg -l | grep '^iU|^rc' | awk '{print $2}' | tr '\n' ' ') --"
apt-get -y -q remove --purge $(dpkg -l | grep -E '^iU|^rc' | awk '{print $2}' | tr '\n' ' ')
exit 0

4
cron.d/HOWTO Normal file
View File

@ -0,0 +1,4 @@
# How to run:
# sudo bash HOWTO filename "cron-expression"
filename=$(basename -s .sample $1)
cat $1 | sed "s/\* \* \* \* \*/$2/" | sudo tee /etc/cron.d/$filename && sudo chmod 644 /etc/cron.d/$filename

3
cron.d/backup.sample Normal file
View File

@ -0,0 +1,3 @@
PATH=/usr/bin:/bin:/usr/local/bin
DEBIAN_FRONTEND=noninteractive
* * * * * root backup

15
cron.d/freedns.sample Normal file
View File

@ -0,0 +1,15 @@
# Cron example for own.strangled.net - will update on 5 minute intervals.
# Works for mac, linux (or any OS with a cron scheduler)
# If you're not familiar with the cron scheduler, you can search for "install a cron", cron is the standard scheduler available on most non-windows systems, mac's, routers, NAS boxes and so on
# Using IPv4 transport
# Test on the console using ..:
# curl http://sync.afraid.org/u/Y0CjTWBpwQ7JKk5VkTm1oZIS/
# To install into cron, on the console enter: crontab -e
# Then paste in the 2 lines at the bottom of this page, then save
# You can check the "/tmp/freedns_own_strangled_net.log" file on your system to verify its happening each 5 minutes
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
0,5,10,15,20,25,30,35,40,45,50,55 * * * * root sleep 42 ; curl -s http://sync.afraid.org/u/Y0CjTWBpwQ7JKk5VkTm1oZIS/ >> /tmp/freedns_own_strangled_net.log 2>/dev/null

View File

@ -0,0 +1,3 @@
PATH=/usr/bin:/bin:/usr/local/bin
DEBIAN_FRONTEND=noninteractive
* * * * * root maintenance

1
cron.d/owncloud.sample Normal file
View File

@ -0,0 +1 @@
* * * * * www-data /usr/bin/php /var/www/owncloud/occ system:cron

1
cron.d/reboot.sample Normal file
View File

@ -0,0 +1 @@
* * * * * root /sbin/reboot

1
cron.d/ttrss.sample Normal file
View File

@ -0,0 +1 @@
* * * * * www-data /usr/bin/php /var/www/tt-rss/update.php --feeds --quiet

0
img/.gitkeep Normal file
View File

4
logrotate.d/HOWTO Normal file
View File

@ -0,0 +1,4 @@
# How to run:
# sudo bash HOWTO filename
filename=$(basename -s .sample $1)
cat $1 | sudo tee /etc/logrotate.d/$filename && sudo chmod 644 /etc/logrotate.d/$filename

View File

@ -0,0 +1,8 @@
/mnt/nfs/HDD/config/logs/maintenance.*.log {
rotate 1
copytruncate
monthly
compress
missingok
notifempty
}

22
logrotate.d/shrink.sample Normal file
View File

@ -0,0 +1,22 @@
/mnt/nfs/HDD/config/img/*.img {
rotate 3
dateext
missingok
nocopytruncate
nocreate
daily
compress
su root root
prerotate
shrink $1
endscript
}
/mnt/nfs/HDD/config/logs/shrink.*.log {
rotate 2
copytruncate
monthly
compress
missingok
notifempty
}

0
logs/.gitkeep Normal file
View File