Added files

This commit is contained in:
Claudio Maggioni 2016-08-06 17:36:23 +02:00 committed by GitHub
parent 1d336af1f2
commit be57d66598
4 changed files with 108 additions and 0 deletions

24
PKGBUILD Normal file
View file

@ -0,0 +1,24 @@
# Maintainer: Claudio Maggioni <youremail@domain.com>
pkgname=astley-rm
pkgver=1
pkgrel=1
pkgdesc="Prevent 'rm -rf' playing Never Gonna Give You Up"
arch=('any')
url="https://praticamentetilde.github.io/linux/2016/07/28/how-to-rickroll-people-launching-rm-rf-on-your-system.html"
license=('custom:unlicense')
makedepends=('git' 'youtube-dl')
_branch=master
#source=("$pkgname-$_branch.zip::https://github.com/praticamentetilde/$pkgname/archive/$_branch.zip")
source=("$pkgname-$_branch.zip")
sha512sums=(SKIP)
package() {
cd "$srcdir"
echo "Placing /usr/bin/astley-rm script..."
install -D -m755 astley-rm.sh "$pkgdir"/usr/bin/astley-rm
echo "Placing /usr/bin/astley-rm-config script..."
install -D -m755 astley-rm-config.sh "$pkgdir"/usr/bin/astley-rm-config
echo "Done."
}

45
astley-rm-config.sh Normal file
View file

@ -0,0 +1,45 @@
#!/bin/bash
usage="$(basename "$0") [-h] [-s] [-f FILE1 (FILE2 ...)] -- Set up the aliases for astley-rm.
where:
-h show this help text
-s output the aliases
-f specify manually the file(s) where to output the aliases.
If the -f option is not used, the aliases will be added to /etc/profile and /etc/bash.bashrc.
Once you have ran this script, restart your shell session in order to apply the aliases
Please remember to manually delete these aliases before uninstall."
config="\n# lines added by /usr/bin/astley-rm-config\nalias rm='/usr/bin/astley-rm'\nalias sudo='sudo '\n"
while getopts ':hsf:' option; do
case "$option" in
h) echo "$usage"
exit
;;
s) echo -e "$config"
exit
;;
f) if [ -z $2 ]; then
echo "Please specify at least one file where to output the aliases."
exit 1
fi;
shift 1
for file in $@; do
echo -e $config >> $file
done
exit
;;
:) printf "missing argument for -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
esac
done
echo -e $config >> /etc/profile
echo -e $config >> /etc/bash.bashrc

3
astley-rm.install Normal file
View file

@ -0,0 +1,3 @@
post_install(){
echo "IMPORTANT! Run /usr/bin/astley-rm-config to set the aliases."
}

36
astley-rm.sh Normal file
View file

@ -0,0 +1,36 @@
#! /bin/bash
# Rickroll whoever tries to desert this system, even root.
# To achieve this, set the appropriate aliases even in /etc/profile and similars.
rickroll(){
echo "Never gonna desert this system..."
xdg-open "http://youtu.be/dQw4w9WgXcQ" 2>&1 &
exit
}
while getopts ":rf-" opt; do
# Prevent '--force' to be detected as -r and -f
if [ "$opt" = "-" ]; then
OPTIND=$OPTIND+1
continue
fi
if [ "$opt" = "r" ] || [ "$opt" = "f" ]; then
if [ "$tmp" = "" ]; then
tmp=$opt
continue
elif [ "$tmp" != "$opt" ]; then
rickroll
fi
fi
done
for var in "$@"
do
if [[ "$var" = "--force" && "$tmp" = "r" ]]; then
rickroll
fi
done
# If it's safe, just run rm
/bin/rm "$@"
exit $?