From be57d665985f19892cdaf4acec23dd99d37db181 Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Sat, 6 Aug 2016 17:36:23 +0200 Subject: [PATCH] Added files --- PKGBUILD | 24 ++++++++++++++++++++++++ astley-rm-config.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ astley-rm.install | 3 +++ astley-rm.sh | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 PKGBUILD create mode 100644 astley-rm-config.sh create mode 100644 astley-rm.install create mode 100644 astley-rm.sh diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..c55048f --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,24 @@ +# Maintainer: Claudio Maggioni +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." +} diff --git a/astley-rm-config.sh b/astley-rm-config.sh new file mode 100644 index 0000000..df05edb --- /dev/null +++ b/astley-rm-config.sh @@ -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 diff --git a/astley-rm.install b/astley-rm.install new file mode 100644 index 0000000..c2151a1 --- /dev/null +++ b/astley-rm.install @@ -0,0 +1,3 @@ +post_install(){ + echo "IMPORTANT! Run /usr/bin/astley-rm-config to set the aliases." +} diff --git a/astley-rm.sh b/astley-rm.sh new file mode 100644 index 0000000..be3c9fc --- /dev/null +++ b/astley-rm.sh @@ -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 $?