mirror of
https://github.com/kneutron/ansitest.git
synced 2025-01-30 05:02:54 +08:00
Add files via upload
This commit is contained in:
parent
9a0b5d68f6
commit
6db8e9f9e4
28
ans-safe-delete-file-dir.sh
Normal file
28
ans-safe-delete-file-dir.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Safely delete file or directory tree with ansible
|
||||||
|
# Author takes NO responsibility for accidents or misuse, USE AT YOUR OWN RISK
|
||||||
|
|
||||||
|
# arg1=server(s), comma-separated
|
||||||
|
# arg2=path/to/file
|
||||||
|
|
||||||
|
# failexit.mrg
|
||||||
|
function failexit () {
|
||||||
|
echo '! Something failed! Code: '"$1 $2" # code # (and optional description)
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Basic sanity
|
||||||
|
[ "$1" = "" ] && failexit 404 "Server(s) not specified as arg 1"
|
||||||
|
[ "$2" = "" ] && failexit 405 "File / Dir not specified as arg 2"
|
||||||
|
|
||||||
|
# "" should catch root
|
||||||
|
for crit in "" bin boot dev etc home lib media mnt opt proc root root/bin run sbin srv sys tmp usr usr/bin usr/sbin var;
|
||||||
|
do
|
||||||
|
if [ "$2" = "/$crit" ] || [ "$2" = "/$crit/" ]; then
|
||||||
|
failexit 999 "ARE YOU INSANE? NO! ( ︶︿︶)_╭∩╮"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Processing servers: $1"
|
||||||
|
ansible $1 -m file -a "dest=$2 state=absent" --become
|
Loading…
x
Reference in New Issue
Block a user