* Mon Nov 20 2017 Jean-Philipe Pialasse <tests@pialasse.com> 0.1.20171120-1.sme

- initial release
This commit is contained in:
2025-10-06 10:12:23 -04:00
parent f7cc4bf85b
commit 5dbb8ffbe7
5 changed files with 160 additions and 82 deletions

View File

View File

@@ -1,55 +1,43 @@
%define name bash-insulter Name: bash-insulter
%define version 1.0 Version: 0.1.20171120
%define release 1 Release: 1%{?dist}
Summary: This is what bash-insulter does. Summary: Randomly insults the user when typing wrong command.
Name: %{name}
Version: %{version} Group: System Environment/Shells
Release: %{release}%{?dist} License: GPL+
Source: %{name}-%{version}.tar.gz URL: https://github.com/hkbakke/bash-insulter
License: GNU GPL version 2 Source0: https://github.com/hkbakke/bash-insulter/tree/master/src/bash.command-not-found
Group: SMEserver/addon BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRoot: %{_tmppath}/%{name}-buildroot BuildArch: noarch
Prefix: %{_prefix} BuildRequires: e-smith-devtools >= 1.13.1-03
BuildArchitectures: noarch
BuildRequires: smeserver-devtools
Requires: smeserver-release >= 11.0
AutoReqProv: no
%description %description
This contribution will introduce some humour in your long day maintaining your SME, or during your long linux learning curve trying to guess what is the right command. Randomly insults the user when typing wrong command.
Change insults as needed :)
%changelog
* Day MMMM DD YYYY <brianr@koozali.org> 1.0-1.sme
- Initial code - create RPM [SME:99999]
%prep %prep
%setup -q
%build %build
perl createlinks
%install %install
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT) mkdir -p $RPM_BUILD_ROOT/etc/profile.d
rm -f %{name}-%{version}-filelist install %{SOURCE0} $RPM_BUILD_ROOT/etc/profile.d/bash-command-not-found.sh
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ /bin/rm -f %{name}-%{version}-filelist
> %{name}-%{version}-filelist /sbin/e-smith/genfilelist $RPM_BUILD_ROOT > %{name}-%{version}-filelist
#echo "%doc COPYING" >> %{name}-%{version}-filelist
#--dir <dir> 'attr(755,user,grp)' \
#--file <file> 'attr(755,root,root)' \
%clean %clean
cd .. rm -rf $RPM_BUILD_ROOT
rm -rf %{name}-%{version}
%pre
%preun
%post %post
%postun %preun
#uninstall
%files -f %{name}-%{version}-filelist %files -f %{name}-%{version}-filelist
%defattr(-,root,root) %defattr(-,root,root,-)
%changelog
* Mon Nov 20 2017 Jean-Philipe Pialasse <tests@pialasse.com> 0.1.20171120-1.sme
- initial release

133
bash.command-not-found Normal file
View File

@@ -0,0 +1,133 @@
print_insult () {
local insults
local selection
insults=(
"Boooo!"
"Don't you know anything?"
"RTFM!"
"Haha, n00b!"
"Wow! That was impressively wrong!"
"Pathetic"
"The worst one today!"
"n00b alert!"
"Your application for reduced salary has been sent!"
"lol"
"u suk"
"lol... plz"
"plz uninstall"
"And the Darwin Award goes to.... ${USER}!"
"ERROR_INCOMPETENT_USER"
"Incompetence is also a form of competence"
"Bad."
"Fake it till you make it!"
"What is this...? Amateur hour!?"
"Come on! You can do it!"
"Nice try."
"What if... you type an actual command the next time!"
"What if I told you... it is possible to type valid commands."
"Y u no speak computer???"
"This is not Windows"
"Perhaps you should leave the command line alone..."
"Please step away from the keyboard!"
"error code: 1D10T"
"ACHTUNG! ALLES TURISTEN UND NONTEKNISCHEN LOOKENPEEPERS! DAS KOMPUTERMASCHINE IST NICHT FÜR DER GEFINGERPOKEN UND MITTENGRABEN! ODERWISE IST EASY TO SCHNAPPEN DER SPRINGENWERK, BLOWENFUSEN UND POPPENCORKEN MIT SPITZENSPARKEN. IST NICHT FÜR GEWERKEN BEI DUMMKOPFEN. DER RUBBERNECKEN SIGHTSEEREN KEEPEN DAS COTTONPICKEN HÄNDER IN DAS POCKETS MUSS. ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN."
"Pro tip: type a valid command!"
"Go outside."
"This is not a search engine."
"(╯°□°)╯︵ ┻━┻"
"¯\_(ツ)_/¯"
"So, I'm just going to go ahead and run rm -rf / for you."
"Why are you so stupid?!"
"Perhaps computers is not for you..."
"Why are you doing this to me?!"
"Don't you have anything better to do?!"
"I am _seriously_ considering 'rm -rf /'-ing myself..."
"This is why you get to see your children only once a month."
"This is why nobody likes you."
"Are you even trying?!"
"Try using your brain the next time!"
"My keyboard is not a touch screen!"
"Commands, random gibberish, who cares!"
"Typing incorrect commands, eh?"
"Are you always this stupid or are you making a special effort today?!"
"Dropped on your head as a baby, eh?"
"Brains aren't everything. In your case they're nothing."
"I don't know what makes you so stupid, but it really works."
"You are not as bad as people say, you are much, much worse."
"Two wrongs don't make a right, take your parents as an example."
"You must have been born on a highway because that's where most accidents happen."
"If what you don't know can't hurt you, you're invulnerable."
"If ignorance is bliss, you must be the happiest person on earth."
"You're proof that god has a sense of humor."
"Keep trying, someday you'll do something intelligent!"
"If shit was music, you'd be an orchestra."
"How many times do I have to flush before you go away?"
)
# Seed "random" generator
RANDOM=$(date +%s%N)
# Only print the insults some of the time
selection=$((${RANDOM}%2))
if [[ ${selection} -lt 1 ]]; then
printf "\n $(tput bold)$(tput setaf 1)$(shuf -n 1 -e "${insults[@]}")$(tput sgr0)\n\n"
fi
}
function_exists () {
# Zsh returns 0 even on non existing functions with -F so use -f
declare -f $1 > /dev/null
return $?
}
#
# The idea below is to copy any existing handlers to another function
# name and insert the insulter in front of the old handler in the
# new handler. By default, neither bash or zsh has has a handler function
# defined, so the default behaviour is replicated.
#
# Also, ensure the handler is only copied once. If we do not ensure this
# the handler would add itself recursively if this file happens to be
# sourced multiple times in the same shell, resulting in a neverending
# stream of insults.
#
#
# Zsh
#
if function_exists command_not_found_handler; then
if ! function_exists orig_command_not_found_handler; then
eval "orig_$(declare -f command_not_found_handler)"
fi
else
orig_command_not_found_handler () {
echo "zsh: command not found: $1"
return 127
}
fi
command_not_found_handler () {
print_insult
orig_command_not_found_handler "$@"
}
#
# Bash
#
if function_exists command_not_found_handle; then
if ! function_exists orig_command_not_found_handle; then
eval "orig_$(declare -f command_not_found_handle)"
fi
else
orig_command_not_found_handle () {
echo "$0: $1: command not found"
return 127
}
fi
command_not_found_handle () {
print_insult
orig_command_not_found_handle "$@"
}

View File

@@ -1,43 +0,0 @@
#!/usr/bin/perl -w
use esmith::Build::CreateLinks qw(:all);
use esmith::Build::Backup qw(:all);
# our event specific for updating with yum without reboot
$event = 'bash-insulter-update';
#add here the path to your templates needed to expand
#see the /etc/systemd/system-preset/49-koozali.preset should be present for systemd integration on all you yum update event
# Maybe need ths in here as well:
# /etc/dar/DailyBackup.dcf - if backup requested
foreach my $file (qw(
/etc/systemd/system-preset/49-koozali.preset
))
{
templates2events( $file, $event );
};
#action needed in case we have a systemd unit
event_link('systemd-default', $event, '10');
event_link('systemd-reload', $event, '50');
#services we might need to restart
#event_services($event, 'xxxx' => 'restart', 'yyyy' => 'restart');
#Backup contrib files
# backup_includes("bash-insulter", qw(
# files(s) to be backed up
#));
#Other possible entries:
#Server manager entry
#panel_link("bash-insulter", 'manager');
#Events to bash-insulter
#$event = 'bash-insulter-bash-insulter';
# safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/bash-insulter");
# templates2events("/etc/bash-insulter/bash-insulter.conf", $event);

0
root/.gitignore vendored
View File