commit 99f395b01b43f6221278c67d8162c36cfc4035e5 Author: tyleo Date: Sun Feb 18 22:29:57 2024 +0100 first commit diff --git a/GITScripts/gitlabmaster.sh b/GITScripts/gitlabmaster.sh new file mode 100644 index 0000000..9c237ba --- /dev/null +++ b/GITScripts/gitlabmaster.sh @@ -0,0 +1,10 @@ +# Script for adding, commiting and pushing on gitlab or github. +echo "Adding all" +sleep 1 +git add * || echo "Adding failed, check your files !" +echo "Commit everything, enter your message !" +sleep 1 +git commit || echo "Commiting failed, check your connection and your git clone" +echo "Pushing ! Enter your ID and Pass !" +git push || echo "Incorrect password, login or bad internet connection (upper 100ms ping)" +echo "Is done ! your master has been updated, active folder is `pwd`" diff --git a/README.md b/README.md new file mode 100755 index 0000000..3485fa7 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +En ce glorieux jour du mardi 29 janvier 2019, moi The Velociraptor place ce projet de scripts libres sous la licence « Fais pas chier ».* + +La copie, la reproduction ou la modification est autorisé en indiquant et conservant le nom de l'auteur. Ce projet est Open Source. + +Copy, Fork or Modifications are allowed by indicating and keeping author name. This project is Open Source. + +The Velociraptor 0.14 (C) 2019.1 + +All my script are runnable using ./ or system $PATH variable. My scripts DOES NOT contain any virus, malware or spyware methods. If you want to ensure you're safe, use cat [file] commande to see my code script. + +Tout mes scripts sont fonctionnels avec le ./ ou la variable systéme $PATH. Mes scripts NE CONTIENNENT aucun virus, malware ou logiciels espions aux méthodes douteuses. Si vous désirez vous assurez qu'aucun virus n'est présent, utiliser la commande cat [fichier] pour voir mes codes. diff --git a/RESSOURCES/decorations.md b/RESSOURCES/decorations.md new file mode 100644 index 0000000..1902e25 --- /dev/null +++ b/RESSOURCES/decorations.md @@ -0,0 +1,491 @@ +██████████████████████████ +█ Tableau des caractéres █ +█Spéciaux pour décoration█ +█ de Script, textes etc..█ +██████████████████████████ + +▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +▒Concept Velociraptor 014▒ +▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ + +██████████████████████████ +║ ╔ ╝ ╚ ╗ □ ╣ ⩇ 🥐 🥖 🍟 +██████████████████████████ +⟸ ⟹ ⟺ ⟼ +██████████████████████████ +⟩⟫⟪⟨⤑⤧ +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ + +██████████████████████████ diff --git a/SH/.stdgame.sh.swp b/SH/.stdgame.sh.swp new file mode 100644 index 0000000..465d663 Binary files /dev/null and b/SH/.stdgame.sh.swp differ diff --git a/SH/additionvar.sh b/SH/additionvar.sh new file mode 100755 index 0000000..2d29cce --- /dev/null +++ b/SH/additionvar.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +number=1 +echo " +███████████████████████████████ +█This script will add your █ +█custom value to the variable █ +█\$number, enter your value █ +█ █ +█it will echo result to you ! █ +█ █ +█Starting value : 1 (number=1)█ +███████████████████████████████ +" +echo $number +while true +do +echo -n "Your value : " +read add +if [[ "$add" =~ [0-9] ]]; then + let "number += add" + echo $number + if [[ $number -ge 1000 ]]; then + echo "Limit reached!" + echo Aborted + exit + fi +elif [[ $add = [Ee]xit ]]; then + exit +elif [[ $add = EXIT ]]; then + exit +elif [[ $add = [Qq]uit ]]; then + exit +elif [[ $add = QUIT ]]; then + exit +else + echo "Numbers only" + exit +fi +done diff --git a/SH/checkuserexistence.sh b/SH/checkuserexistence.sh new file mode 100755 index 0000000..6369b3e --- /dev/null +++ b/SH/checkuserexistence.sh @@ -0,0 +1,9 @@ +#!/bin/sh +echo -n "Enter a username to check: " +read name +if grep $name /etc/passwd > /dev/null +then + echo "$name is on this system" +else + echo "$name does not exist" +fi diff --git a/SH/checkuserexistenceloop.sh b/SH/checkuserexistenceloop.sh new file mode 100755 index 0000000..e75ce6d --- /dev/null +++ b/SH/checkuserexistenceloop.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +name=$USER + +while [[ $name = * ]]; do + echo -n "Enter a username to check: " + read name + if grep $name /etc/passwd > /dev/null + then + echo "$name is on this system" + else + echo "$name does not exist" + fi +done diff --git a/SH/chooseyourcalendar.sh b/SH/chooseyourcalendar.sh new file mode 100755 index 0000000..ab77409 --- /dev/null +++ b/SH/chooseyourcalendar.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# This condition allow you to choose between cal or calendar commands. +ACTIVECOMMAND= +clear +echo "Choose your calendar !" +echo " Simple / Complex " +read ACTIVECOMMAND +# --------------------------- +if [ $ACTIVECOMMAND = Simple ]; then + cal +elif [ $ACTIVECOMMAND = Complex ]; then + calendar +elif [ $ACTIVECOMMAND = Simplex ]; then + echo "En fait, t'est complétement con." +else + echo "Eheh, no correspondance." +fi diff --git a/SH/dialog01.sh b/SH/dialog01.sh new file mode 100755 index 0000000..530da7a --- /dev/null +++ b/SH/dialog01.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +printf ' +Dialogue entre deux personne +' +echo "Type 'start'" +read start +if [[ $start = start ]]; then + read dialog + echo "Bonjour" + read dialog + echo "Oui et toi?" + exit +else + echo + exit +fi \ No newline at end of file diff --git a/SH/echodisturb.sh b/SH/echodisturb.sh new file mode 100755 index 0000000..ee968ad --- /dev/null +++ b/SH/echodisturb.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Using pipes and redirection to make the echo disturbing +echo "Je m'appelle Henry" +echo "Je m'appelle Henry" | tr 'Henry' 'Hanry' +echo "Je m'appelle Henry" | tr 'appelle' 'alleppe' +echo "Je m'appelle Henry" | tr 'Je' 'Tu' +echo "Je m'appelle Henry" | tr 'm' 'p' +echo "Je m'appelle Henry" | tr 'appe' 'mapp' +echo "Je m'appelle Henry" | tr "Je m'appelle Henry" "yrneH elleppa'm eJ" + +# Pipes can be used to replace characters (or Char). + +echo "1" | tr '1' '2' # this will show 2 and not 1. +echo "no" | tr 'no' 'yes' # this will show yes and not no. + +# Pipes can interfer with result of commands, for example : +echo "Normal LS" +ls -l +echo "Anormal LS" +ls -l | tr 'drwxrwxrjanvdecnovjunavrmayaug' '00' +echo "The command is : ls -l | tr 'drwxrwxrjanvdecnovjunavrmayaug' '00'" +echo "Or..." +ls -l | echo "Ahah !" +echo 'The Command is : ls -l | echo "Ahah !"' +echo "This make the command LS in bad condition due to pipe." + +echo "The Tr command is usefull for maintenancy taskes or for changing a sensible value." diff --git a/SH/echogame.sh b/SH/echogame.sh new file mode 100755 index 0000000..8830653 --- /dev/null +++ b/SH/echogame.sh @@ -0,0 +1,90 @@ +#!/bin/sh +# The game of CD, MV and CP ! +# Experimental. This script will created and use only one additional folder. +# -------------------------------------------------------------------------- +mkdir ./ScriptGameCDMVCP +cd ./ScriptGameCDMVCP +sleep 2 +mkdir folder1 folder2 folder3 +sleep 2 +touch file1 file2 file3 +# Creation finished. + +# Now, moving file1 to folder1 +mv file1 folder1/ +# Now, moving file2 to folder2 +mv file2 folder2/ +# Now, moving file3 to folder3 +mv file3 folder3/ + +echo "Waiting 10 seconds, and showing the part of script that has moved theses files!" +printf ' +# Now, moving file1 to folder1 +mv file1 folder1/ +# Now, moving file2 to folder2 +mv file2 folder2/ +# Now, moving file3 to folder3 +mv file3 folder3/ \n +' +echo "CTRL+C to abort" +echo "Waiting..." +sleep 10 # Waiting 10 seconds to let you see the script. + +# Now, renaming all "file*" by "data*" with mv command +mv ./folder1/file1 ./folder1/data1 +mv ./folder2/file2 ./folder2/data2 +mv ./folder3/file3 ./folder3/data3 +echo "Done !" +ls -lR folder1 folder2 folder3 # Showing the work ! Using ls with Recursivity +sleep 10 # Always let the time to see the LS. Is very important to make the time easier. +echo "Showing the script !" +printf ' +# Now, renaming all "file*" by "data*" with mv command +mv ./folder1/file1 ./folder1/data1 +mv ./folder2/file2 ./folder2/data2 +mv ./folder3/file3 ./folder3/data3 +echo "Done !" +ls -R folder1 folder2 folder3 # Showing the work ! Using ls with Recursivity \n +' +# Now, copying all files. The objective is to get all data* into all folder* +cp ./folder1/data1 ./folder2 +cp ./folder2/data2 ./folder1 # For each folders, we use two commands. and we separate with a line in commentaries +# ------------------------------------------------- +cp ./folder3/data3 ./folder2 +cp ./folder2/data2 ./folder3 # Doing the same thing +# ------------------------------------------------- +cp ./folder1/data1 ./folder3 +cp ./folder3/data3 ./folder1 # Doing the same thing another time +# ------------------------------------------------- +# Showing the script : +echo "Now, you can see the script !" +printf ' +# Now, copying all files. The objective is to get all data* into all folder* +cp ./folder1/data1 ./folder2 +cp ./folder2/data2 ./folder1 # For each folders, we use two commands. and we separate with a line in commentaries +# ------------------------------------------------- +cp ./folder3/data3 ./folder2 +cp ./folder2/data2 ./folder3 # Doing the same thing +# ------------------------------------------------- +cp ./folder1/data1 ./folder3 +cp ./folder3/data3 ./folder1 # Doing the same thing another time +# ------------------------------------------------- \n +' + +# after that, we have copied everything. Now, we will show the work. +ls -R folder1 folder2 folder3 +sleep 10 + +echo "This script is a very simple script." +printf ' +For learning, for exploring and for editing them as you want ! +' + +# after, the script will clean up by deleting the folder completely and recursively. +# Try to loop ! + +rm -rf ../ScriptGameCDMVCP # Removing everything in folder1, folder2 and folder3 +echo "The LS :" +echo "`ls -laR ./`\n Listing done!" +echo "The file has been removed successfully!" +echo "script end." diff --git a/SH/echogamenorm.sh b/SH/echogamenorm.sh new file mode 100755 index 0000000..1006232 --- /dev/null +++ b/SH/echogamenorm.sh @@ -0,0 +1,95 @@ +#!/bin/sh +# The game of CD, MV and CP ! (no rm version) +# Experimental. This script will created and use only one additional folder. + +# CLEANING +rm -rf ./ScriptGameCDMVCP 2> /dev/null + +# -------------------------------------------------------------------------- +mkdir ./ScriptGameCDMVCP +cd ./ScriptGameCDMVCP +sleep 2 +mkdir folder1 folder2 folder3 +sleep 2 +touch file1 file2 file3 +# Creation finished. + +# Now, moving file1 to folder1 +mv file1 folder1/ +# Now, moving file2 to folder2 +mv file2 folder2/ +# Now, moving file3 to folder3 +mv file3 folder3/ + +echo "Waiting 10 seconds, and showing the part of script that has moved theses files!" +printf ' +# Now, moving file1 to folder1 +mv file1 folder1/ +# Now, moving file2 to folder2 +mv file2 folder2/ +# Now, moving file3 to folder3 +mv file3 folder3/ \n +' +echo "CTRL+C to abort" +echo "Waiting..." +sleep 10 # Waiting 10 seconds to let you see the script. + +# Now, renaming all "file*" by "data*" with mv command +mv ./folder1/file1 ./folder1/data1 +mv ./folder2/file2 ./folder2/data2 +mv ./folder3/file3 ./folder3/data3 +echo "Done !" +ls -lR folder1 folder2 folder3 # Showing the work ! Using ls with Recursivity +sleep 10 # Always let the time to see the LS. Is very important to make the time easier. +echo "Showing the script !" +printf ' +# Now, renaming all "file*" by "data*" with mv command +mv ./folder1/file1 ./folder1/data1 +mv ./folder2/file2 ./folder2/data2 +mv ./folder3/file3 ./folder3/data3 +echo "Done !" +ls -R folder1 folder2 folder3 # Showing the work ! Using ls with Recursivity \n +' +# Now, copying all files. The objective is to get all data* into all folder* +cp ./folder1/data1 ./folder2 +cp ./folder2/data2 ./folder1 # For each folders, we use two commands. and we separate with a line in commentaries +# ------------------------------------------------- +cp ./folder3/data3 ./folder2 +cp ./folder2/data2 ./folder3 # Doing the same thing +# ------------------------------------------------- +cp ./folder1/data1 ./folder3 +cp ./folder3/data3 ./folder1 # Doing the same thing another time +# ------------------------------------------------- +# Showing the script : +echo "Now, you can see the script !" +printf ' +# Now, copying all files. The objective is to get all data* into all folder* +cp ./folder1/data1 ./folder2 +cp ./folder2/data2 ./folder1 # For each folders, we use two commands. and we separate with a line in commentaries +# ------------------------------------------------- +cp ./folder3/data3 ./folder2 +cp ./folder2/data2 ./folder3 # Doing the same thing +# ------------------------------------------------- +cp ./folder1/data1 ./folder3 +cp ./folder3/data3 ./folder1 # Doing the same thing another time +# ------------------------------------------------- \n +' + +# after that, we have copied everything. Now, we will show the work. +ls -R folder1 folder2 folder3 +sleep 10 + +echo "This script is a very simple script." +printf ' +For learning, for exploring and for editing them as you want ! +' + +# after, the script will clean up by deleting the folder completely and recursively. +# Try to loop ! + +echo "This version let the folder intact. You can explore it." +echo "This script delete any old folder named exactly same. Be aware!" +echo "The LS :" +echo "`ls -laR ./`\n Listing done!" +echo "The file has been removed successfully!" +echo "script end." diff --git a/SH/echoloop1.sh b/SH/echoloop1.sh new file mode 100755 index 0000000..88cb6d1 --- /dev/null +++ b/SH/echoloop1.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# -------------------------------- +while true +do + clear + echo "1" + sleep 1 + clear + echo "2" + sleep 1 + clear + echo "3" + sleep 1 + clear + echo "4" + sleep 1 + clear + echo "5" + sleep 1 + clear + echo "Bah alors, faut m'arréter !" + sleep 1 + clear + echo "CTRL+C !" + sleep 3 + clear +done diff --git a/SH/echols.sh b/SH/echols.sh new file mode 100755 index 0000000..2842f11 --- /dev/null +++ b/SH/echols.sh @@ -0,0 +1,9 @@ +#!/bin/sh +while true +do + ls + echo " " + echo "Updating..." + sleep 1 + clear +done diff --git a/SH/echoperma.sh b/SH/echoperma.sh new file mode 100755 index 0000000..d30bdce --- /dev/null +++ b/SH/echoperma.sh @@ -0,0 +1,17 @@ +#!/bin/sh +clear +echo "After this title, press CTRL+C to stop the script." +echo "This script is innofensive and has been created for" +echo "learning. See it by typing < cat [file] >" +echo " " +echo "Waiting 5 seconds" +sleep 5 +# Start of script ! +while true +do + echo "Perma Echo" + clear +done + +# In this script, you can see an infinite loop without any sleep commands, That produce permanently +# same command and the command is in loop state. That can be usefull for doing anything infinitly. diff --git a/SH/fakeloadingscreen1.sh b/SH/fakeloadingscreen1.sh new file mode 100755 index 0000000..cf763a9 --- /dev/null +++ b/SH/fakeloadingscreen1.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +printf ' +------------------- +FAKE LOADING SCREEN +-------------------\n +' +echo "Type 'start' to start loading !" +echo "CTRL+C to stop loading !" +read loading +while true +do +if [[ $loading = start ]]; then + clear + echo "---------" + echo "Loading ." + echo "---------" + sleep 1 + clear + echo "----------" + echo "Loading .." + echo "----------" + sleep 1 + clear + echo "-----------" + echo "Loading ..." + echo "-----------" + sleep 1 +else + exit +fi +done diff --git a/SH/fakeloadingscreen2.sh b/SH/fakeloadingscreen2.sh new file mode 100755 index 0000000..9a4d400 --- /dev/null +++ b/SH/fakeloadingscreen2.sh @@ -0,0 +1,53 @@ +#!/bin/bash +while true +do + clear + echo "-" + sleep 1 + clear + echo "--" + sleep 2 + clear + echo "---" + sleep 3 + clear + echo "----" + sleep 4 + clear + echo "-----" + sleep 5 + clear + echo "------" + sleep 6 + clear + echo "-------" + sleep 7 + clear + echo "--------" + sleep 8 + clear + echo "---------" + sleep 9 + clear + echo "----------" + sleep 10 + clear + echo "-----------" + sleep 11 + clear + echo "------------" + sleep 12 + clear + echo "-------------" + sleep 13 + clear + echo "--------------" + sleep 14 + clear + echo "---------------" + sleep 15 + clear + echo "----------------" + sleep 1 + clear +done diff --git a/SH/fakeloadingscreen3.sh b/SH/fakeloadingscreen3.sh new file mode 100755 index 0000000..829266a --- /dev/null +++ b/SH/fakeloadingscreen3.sh @@ -0,0 +1,53 @@ +#!/bin/bash +while true +do + clear + echo "-" + sleep 1 + clear + echo "--" + sleep 1 + clear + echo "---" + sleep 1 + clear + echo "----" + sleep 1 + clear + echo "-----" + sleep 1 + clear + echo "------" + sleep 1 + clear + echo "-------" + sleep 1 + clear + echo "--------" + sleep 1 + clear + echo "---------" + sleep 1 + clear + echo "----------" + sleep 1 + clear + echo "-----------" + sleep 1 + clear + echo "------------" + sleep 1 + clear + echo "-------------" + sleep 1 + clear + echo "--------------" + sleep 1 + clear + echo "---------------" + sleep 1 + clear + echo "----------------" + sleep 1 + clear +done diff --git a/SH/greaterthancent.sh b/SH/greaterthancent.sh new file mode 100755 index 0000000..24d00ca --- /dev/null +++ b/SH/greaterthancent.sh @@ -0,0 +1,12 @@ +#!/bin/bash +echo "Choose a number greater than 100" +read lecture +number=${lecture:-0} +while [ $number -le 100 ] +do + echo "$number is not greater than 100." + echo "Please enter a number greated than 100!" + read lecture + number=${lecture:-0} +done +echo "Finally, $number is greater than 100 !" diff --git a/SH/hourinlive.sh b/SH/hourinlive.sh new file mode 100755 index 0000000..0d94ec7 --- /dev/null +++ b/SH/hourinlive.sh @@ -0,0 +1,8 @@ +#!/bin/bash +while true +do + date +%H:%M:%S + echo "CTRL+C to stop" + sleep 1 + clear +done diff --git a/SH/lstotextfile.sh b/SH/lstotextfile.sh new file mode 100755 index 0000000..f299c11 --- /dev/null +++ b/SH/lstotextfile.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +echo " +------------------------ +Add ls results to a file +------------------------ + +You can choose extension and filename +separately. + +The file will be stored into a folder +named "LSFILEFOLDER" +" +echo "Choose your filename without extension : " +echo +echo -n "filename=" +read fname +echo +echo "Choose your extension : " +echo -n "extension=." +read extf +if [ -f "./LSFILEFOLDER/$fname.$extf" ] +then + echo "File exist" + echo Aborting! + exit +elif [ test ] +then + mkdir ./LSFILEFOLDER &>> /dev/null + touch ./LSFILEFOLDER/$fname.$extf &>> /dev/null + ls ./LSFILEFOLDER/$fname.$extf &>> /dev/null + echo + echo "Now, choose a location of ls command to make a result!" + echo + echo -n "/" + read tree + ls /$tree &>> ./LSFILEFOLDER/$fname.$extf +fi diff --git a/SH/multicondition.sh b/SH/multicondition.sh new file mode 100755 index 0000000..d42dc43 --- /dev/null +++ b/SH/multicondition.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +echo "This script is designed for demonstrating variable into conditions" +echo "------------------------------------------------------------------" +echo "You can enter any other words than asked for seeing the behavior !" +echo +echo "In this script, you will set the variable by READ command :" +echo +echo -n "Enter 'hello' : " +read hello +echo "The variable \$hello is now set to $hello" +if [[ $hello = hello ]]; then + echo "The value is $hello and correspond to the asked one" +else + echo "The value is $hello and do not correspond to the asked one" +fi +echo +echo -n "Another example, enter anything you want excepting 'world' :" +read world +echo +echo "Now, the \$world variable is set to $world" +echo +if [[ $world = world ]]; then + echo "You have entered '$world' and is the excepting one !" +elif [[ $world = * ]]; then + echo "You have entered '$world' and it's OK" +fi +echo +echo "Script Ended." diff --git a/SH/oneplusoneequaltwo.sh b/SH/oneplusoneequaltwo.sh new file mode 100755 index 0000000..058c6e0 --- /dev/null +++ b/SH/oneplusoneequaltwo.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +echo "Hey, this is a little calcul with 2 try :" +echo -n "1+1=" +read result +if [[ $result = 2 ]]; then + echo "Good ! It is right !" +elif [[ $result = * ]]; then + echo "Wrong answer !" + echo "Retry !" + echo -n "1+1=" + read result + if [[ $result = 2 ]]; then + echo "Yes ! It is right !" + elif [[ $result = * ]]; then + echo "Ooh nooo... Is wrong !" + echo "Retry !" + echo -n "1+1=" + read result + if [[ $result = 2 ]]; then + echo "Yes ! IS RIGHT !!!!" + elif [[ $result = * ]]; then + echo "Ahahahahha nooo !!! Loooser !" + fi + fi +fi diff --git a/SH/shwithdoublecrochet.sh b/SH/shwithdoublecrochet.sh new file mode 100755 index 0000000..f870aed --- /dev/null +++ b/SH/shwithdoublecrochet.sh @@ -0,0 +1,5 @@ +#!/bin/bash +ECH=0 +if [[ ECH=0 ]]; then + echo "$ECH" +fi diff --git a/SH/simpleconditionvar.sh b/SH/simpleconditionvar.sh new file mode 100755 index 0000000..6616eae --- /dev/null +++ b/SH/simpleconditionvar.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +variable=testvariable +if [ $variable = testvariable ] +then + echo "Variable $variable" +fi diff --git a/SH/theconditionofdeath.sh b/SH/theconditionofdeath.sh new file mode 100755 index 0000000..d49b761 --- /dev/null +++ b/SH/theconditionofdeath.sh @@ -0,0 +1,22 @@ +#!/bin/sh +echo "Ce script étudie l'usage des conditions IF-FI" +echo "---------------------------------------------" +echo "Alors, nous allons prendre un exemple :" +# ------------------------------------------------- +echo "Choisissez entre 'on', 'off' et 'middle'" +read DEATH +echo "You have choosen $DEATH" +echo PLEASE +sleep 1 +echo WAIT +sleep 3 +# - - - - - - - - - - - - - - - - - - - - - - - - - +if [ $DEATH = off ]; then + echo "Il est mort" +elif [ $DEATH = on ]; then + echo "Il est vivant" +elif [ $DEATH = middle ]; then + echo "Il est quelque chose mais je ne sais pas quoi !" +else + echo "Réponse incorrectesh" +fi diff --git a/SH/theparrot.sh b/SH/theparrot.sh new file mode 100755 index 0000000..2bbcb46 --- /dev/null +++ b/SH/theparrot.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +while true +echo -n "Choose a number, I will repeat it after you : " +read magicnumber +do + if [[ $magicnumber = * ]]; then + echo "$magicnumber" + echo -n "Choose another one" + read magicnumber + echo "$magicnumber" + fi +done diff --git a/SH/userisroot.sh b/SH/userisroot.sh new file mode 100755 index 0000000..25354fe --- /dev/null +++ b/SH/userisroot.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +if [ $USER = root ]; then # Check for USER=root + echo "You are root" +else + echo "You are not root !" +fi +# ------------------------------------------------------------------------ # +# This script say "You are not root" when the variable $USER is not "root" # +# If the script see "root" in $USER variable, it will say "You are root"-- # +# In the case of nothing is into the variable, it will say a joke.-------- # +# ------------------------------------------------------------------------ # diff --git a/SH/variablegame.sh b/SH/variablegame.sh new file mode 100755 index 0000000..709e7ee --- /dev/null +++ b/SH/variablegame.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# Registering variables +VARIABLE0001=1 +VARIABLE0002=2 +VARIABLE0003=3 +VARIABLE0004=4 +VARIABLE0005=5 +OUTOFRANGE=`echo "Out Of Range !"` +# --------------------- + +# We will use variables for creating computing : + +echo "$VARIABLE0001 + $VARIABLE0001 = $VARIABLE0002" +echo "$VARIABLE0002 + $VARIABLE0002 = $VARIABLE0004" +echo "$VARIABLE0004 + $VARIABLE0004 = $OUTOFRANGE" +echo "$VARIABLE0005 = $VARIABLE0005 after that, is $OUTOFRANGE" + +# End diff --git a/SH/variablesonscene.sh b/SH/variablesonscene.sh new file mode 100755 index 0000000..7d225ff --- /dev/null +++ b/SH/variablesonscene.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Examples of variables +FILENAME=1 +ANIMAL=2 +COCHONS=3 +CECIESTUNEVARIABLE=4 +echo "$FILENAME + $ANIMAL = $COCHONS" +echo "Si on ajoute $FILENAME à $COCHONS on obtient alors" +echo "$CECIESTUNEVARIABLE" diff --git a/SH/viveles.sh b/SH/viveles.sh new file mode 100755 index 0000000..1593a6a --- /dev/null +++ b/SH/viveles.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +echo "Hey, tu sais quoi?" +echo "Dit moi un mot et je dirait que j'en suis ravi" +echo +echo -n "Votre mot : " +read word +echo +echo "D'accord..." +echo "Hmmm... (L'homme réfléchissait alors)" +sleep 5 +echo "Je suis tout a fait ravis de ce $word" +# Ainsi, ce script montre une simple varable $word +# nous l'utilisons ici en tant que valeur d'entrée +# c'est elle qui sera défini par l'utilisateur +# à la commande "read [variable]". Imaginez faire +# cela dans des conditions, des cases ou même un +# simple bash script ! C'est magique ! \ No newline at end of file diff --git a/SH/writethetext.sh b/SH/writethetext.sh new file mode 100755 index 0000000..7cfa583 --- /dev/null +++ b/SH/writethetext.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# The objective is to let the user writing their own text. +# Five lines, defined by five variables : +one= +two= +three= +four= +five= +# At start, variables are empty. +# Now, asking for each lines : +echo "Enter the first line" +read one +echo "Enter the second one" +read two +echo "Enter the third one" +read three +echo "Enter the four one" +read four +echo "Enter the five one" +read five +echo +echo "Ok, you have entered :" +echo $one +echo $two +echo $three +echo $four +echo $five diff --git a/SH/writethetextonfile.sh b/SH/writethetextonfile.sh new file mode 100755 index 0000000..a99d7cc --- /dev/null +++ b/SH/writethetextonfile.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# The objective is to let the user writing their own text. +# Five lines, defined by five variables : +one= +two= +three= +four= +five= +file=filename.txt +# At start, variables are empty. +# Now, asking for each lines : +echo "Enter the first line" +read one +echo "Enter the second one" +read two +echo "Enter the third one" +read three +echo "Enter the four one" +read four +echo "Enter the five one" +read five +echo +echo -n "Choose your filename : " +read file +echo +echo "Ok, your text will be written on $file" +echo $one >> ./$file +echo $two >> ./$file +echo $three >> ./$file +echo $four >> ./$file +echo $five >> ./$file +echo "Done ! on file ($file)" +echo "----------------------" +cat ./$file diff --git a/SH_EXPERIMENTAL/LOOP1/README.md b/SH_EXPERIMENTAL/LOOP1/README.md new file mode 100644 index 0000000..88ebc59 --- /dev/null +++ b/SH_EXPERIMENTAL/LOOP1/README.md @@ -0,0 +1,2 @@ +Attention, les script présent dans SH_EXPERIMENTAL/LOOP +***sont des scripts loop boucle infinies. Faire CTRL+C pour stopper !*** diff --git a/SH_EXPERIMENTAL/LOOP1/script1 b/SH_EXPERIMENTAL/LOOP1/script1 new file mode 100644 index 0000000..a5f5918 --- /dev/null +++ b/SH_EXPERIMENTAL/LOOP1/script1 @@ -0,0 +1,4 @@ +#!/bin§bash +echo "Script 1 en cours d'execution" +sleep 1 +sh script2 diff --git a/SH_EXPERIMENTAL/LOOP1/script2 b/SH_EXPERIMENTAL/LOOP1/script2 new file mode 100644 index 0000000..d802d9e --- /dev/null +++ b/SH_EXPERIMENTAL/LOOP1/script2 @@ -0,0 +1,4 @@ +#!/bin/bash +echo "Script 2 en cours d'execution" +sleep 1 +sh script3 diff --git a/SH_EXPERIMENTAL/LOOP1/script3 b/SH_EXPERIMENTAL/LOOP1/script3 new file mode 100644 index 0000000..851e0da --- /dev/null +++ b/SH_EXPERIMENTAL/LOOP1/script3 @@ -0,0 +1,4 @@ +#!/bin/bash +echo "Script 3 en cours d'execution" +sleep 1 +sh script1 diff --git a/SH_EXPERIMENTAL/READMEHERE.md b/SH_EXPERIMENTAL/READMEHERE.md new file mode 100644 index 0000000..2670c83 --- /dev/null +++ b/SH_EXPERIMENTAL/READMEHERE.md @@ -0,0 +1,6 @@ +All projects in this folder are EXPERIMENTAL but very interesting. + +Theses scripts explore different maner to create interactive scripts. + +Theses script will NEVER include comments (# ....) + diff --git a/SH_EXPERIMENTAL/chooseyournumber.sh b/SH_EXPERIMENTAL/chooseyournumber.sh new file mode 100644 index 0000000..7ba92a0 --- /dev/null +++ b/SH_EXPERIMENTAL/chooseyournumber.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +question='Please enter your choice' +options=("Option 1" "Option 2" "Option 3" "Quit") +select opt in "${options[@]}" +do + case $opt in + "Option 1") + echo "Chosen 1 !" + ;; + "Option 2") + echo "Chosen 2 !" + ;; + "Option 3") + echo "Chosen 3 !" + ;; + "Quit") + break + ;; + *) echo "Invalid" + esac +done diff --git a/SH_PROJECTS/binaryiptodecimalip.sh b/SH_PROJECTS/binaryiptodecimalip.sh new file mode 100755 index 0000000..1f5ed31 --- /dev/null +++ b/SH_PROJECTS/binaryiptodecimalip.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +ip1=0 +ip2=0 +ip3=0 +ip4=0 +cb1= +cb2= +cb3= +cb4= +printf ' +------------------------------ + IP BIN TO IP DEC CONVERTER +------------------------------ +This script will convert your binary +ip address to decimal one. + +Enter all dot to dot values +(xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx) + +' +echo "Enter your first dot (________.) : " +read ip1 +echo "ibase=2;obase=A;$ip1" | bc > ....cb1 +echo "Enter your second dot ($ip1.________): ." +read ip2 +echo "ibase=2;obase=A;$ip2" | bc > ....cb2 +echo "Enter your third dot ($ip1.$ip2.________): ." +read ip3 +echo "ibase=2;obase=A;$ip3" | bc > ....cb3 +echo "Enter your fourth ($ip1.$ip2.$ip3.________): ." +read ip4 +echo "ibase=2;obase=A;$ip4" | bc > ....cb4 +echo "Your binary ip address :" +echo "$ip1.$ip2.$ip3.$ip4" +echo "Translated in Decimal :" +echo "`cat ....cb1`.`cat ....cb2`.`cat ....cb3`.`cat ....cb4`" +echo +echo "Finished." +rm ....cb1 ....cb2 ....cb3 ....cb4 \ No newline at end of file diff --git a/SH_PROJECTS/binarytodecimal.sh b/SH_PROJECTS/binarytodecimal.sh new file mode 100755 index 0000000..ac7a826 --- /dev/null +++ b/SH_PROJECTS/binarytodecimal.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# This script translate decimal read values to binary one. +number=0 +printf ' +------------------------------- + BINARY TO DECIMAL CONVERTER +------------------------------- +This script will translate your +binary number to decimal one. + +Using bc command +(need to be present on your system to work) +' +echo -n "Enter your value : " +read number +echo "Converting!" +sleep 1 +echo "ibase=2;obase=A;$number" | bc \ No newline at end of file diff --git a/SH_PROJECTS/calendarmenu.sh b/SH_PROJECTS/calendarmenu.sh new file mode 100755 index 0000000..77c1ff6 --- /dev/null +++ b/SH_PROJECTS/calendarmenu.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# This script show a menu to choose type of calendar between Simple, Complex and Date. +printf ' +---------------------------------- + DATE AND CALENDAR CHOOSER MENU +---------------------------------- +Choose between : + +current : calendar of current month +three : calendar of three month and current one at middle +date : Show the date of today +hour : Show the clock (HH:MM:SS) +' +echo -n "Your choice : " +read cli +echo +if [[ $cli = [Cc]urrent ]] +then + cal +elif [[ $cli = [Tt]hree ]] +then + cal -3 +elif [[ $cli = [Dd]ate ]] +then + echo "La date d'aujourd'hui : `date +"%A %d %B %Y"`" +elif [[ $cli = [Hh]our ]] +then + echo "L'heure actuelle : `date +%H:%M:%S`" +fi diff --git a/SH_PROJECTS/cgamesx785qs_data/.elifscript b/SH_PROJECTS/cgamesx785qs_data/.elifscript new file mode 100755 index 0000000..5591748 --- /dev/null +++ b/SH_PROJECTS/cgamesx785qs_data/.elifscript @@ -0,0 +1,9 @@ +if [[ conditions ]]; then + actions +elif [[ conditions ]]; then + actions +elif [[ conditions ]]; then + actions +fi + +# You can use multiple times ELIF conditions \ No newline at end of file diff --git a/SH_PROJECTS/cgamesx785qs_data/.elsescript b/SH_PROJECTS/cgamesx785qs_data/.elsescript new file mode 100755 index 0000000..3daa880 --- /dev/null +++ b/SH_PROJECTS/cgamesx785qs_data/.elsescript @@ -0,0 +1,3 @@ +else [[ conditions ]]; then + actions +fi # the fi is if inverted (inversé) \ No newline at end of file diff --git a/SH_PROJECTS/cgamesx785qs_data/.ifscript b/SH_PROJECTS/cgamesx785qs_data/.ifscript new file mode 100755 index 0000000..247cc6e --- /dev/null +++ b/SH_PROJECTS/cgamesx785qs_data/.ifscript @@ -0,0 +1,3 @@ +if [[ conditions ]]; then + actions +fi diff --git a/SH_PROJECTS/conditiontraininggame.sh b/SH_PROJECTS/conditiontraininggame.sh new file mode 100755 index 0000000..2deb17a --- /dev/null +++ b/SH_PROJECTS/conditiontraininggame.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +# Start and between +IF= +ELIF= +ELSE= +# Ending +THEN= +FI= +# Starting script +printf ' +------------------------------- + IF, ELIF, ELSE, THEN et FI. +------------------------------- +Ce jeu est en Français et sera +toujours traduit en anglais + +This game is in French and will +always be translated to English + +------------------------------- +le but est simple +the objective is easy + +vous diposez des mots suivants : +you own theses words : + +if, fi, then, else, et elif. + +Aprés avoir lu le systéme de condition +After reading condition system : + +A chaque fois que un mot apparait +sur le terminal, saisir le mot suivant. +For each time of word appear in the +terminal, type the next word. +' +echo +echo -n "Go? [Y/n]" +read go +if [[ $go = [Yy] ]]; then + echo "Starting !" + echo + echo -n "if [[ test ]]; " + read IF + if [[ $IF = then ]]; then + echo "Good !" + echo "This is an example of code :" + cat ./cgamesx785qs_data/.ifscript + elif [[ $IF = * ]]; then + echo "No, the right answer is 'then'" + echo "This is an example of code :" + cat ./cgamesx785qs_data/.ifscript + fi + echo + echo -n "else " + read ELSE + if [[ $ELSE = fi ]]; then + echo "Good !" + echo "This is an example of code :" + cat ./cgamesx785qs_data/.elsescript + elif [[ $ELSE = * ]]; then + echo "Bad answer, the right answer is 'fi'" + echo "This is an example of code :" + cat ./cgamesx785qs_data/.elsescript + fi + echo "the last one :" + echo "if, tip : Excepting 'then', When I want to do other thing in certain cases" + read ELIF + if [[ $ELIF = elif ]]; then + echo "Good answer !" + echo "This is an example of code :" + cat ./cgamesx785qs_data/.elifscript + elif [[ $ELIF = * ]]; then + echo "Bad answer, the right is : elif, used to make another condition after the first one." + echo "This is an example of code :" + cat ./cgamesx785qs_data/.elifscript + fi +elif [[ $go = [Nn] ]];[[ $go = " " ]]; then + echo "Game aborted !" + exit +fi diff --git a/SH_PROJECTS/decimaliptobinaryip.sh b/SH_PROJECTS/decimaliptobinaryip.sh new file mode 100755 index 0000000..037f95b --- /dev/null +++ b/SH_PROJECTS/decimaliptobinaryip.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +ip1=0 +ip2=0 +ip3=0 +ip4=0 +bc1= +bc2= +bc3= +bc4= +printf ' +------------------------------ + IP DEC TO IP BIN CONVERTER +------------------------------ +This script will convert your ip address +to binary one. + +Enter all dot to dot values (xxx.xxx.xxx.xxx) + +' +echo "Enter your first dot ___. : " +read ip1 +echo "scale=8;obase=2;$ip1" | bc > ....bc1 +echo "Enter your second dot $ip1.___.: ." +read ip2 +echo "scale=8;obase=2;$ip2" | bc > ....bc2 +echo "Enter your third dot $ip1.$ip2.___.: ." +read ip3 +echo "scale=8;obase=2;$ip3" | bc > ....bc3 +echo "Enter your fourth $ip1.$ip2.$ip3.___: ." +read ip4 +echo "scale=8;obase=2;$ip4" | bc > ....bc4 +echo "Your ip address :" +echo "$ip1.$ip2.$ip3.$ip4" +echo "Translated in Binary :" +echo "`cat ....bc1`.`cat ....bc2`.`cat ....bc3`.`cat ....bc4`" +echo +echo "Finished." +rm ....bc1 ....bc2 ....bc3 ....bc4 diff --git a/SH_PROJECTS/decimaltobinary.sh b/SH_PROJECTS/decimaltobinary.sh new file mode 100755 index 0000000..5e98cbb --- /dev/null +++ b/SH_PROJECTS/decimaltobinary.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# This script translate decimal read values to binary one. +number=0 +printf ' +------------------------------- + DECIMAL TO BINARY CONVERTER +------------------------------- +This script will translate your +decimal number to binary one. + +Using bc command +(need to be present on your system to work) +' +echo -n "Enter your value : " +read number +echo "Converting!" +sleep 1 +echo "obase=2;$number" | bc \ No newline at end of file diff --git a/SH_PROJECTS/installzshyesorno.sh b/SH_PROJECTS/installzshyesorno.sh new file mode 100755 index 0000000..85bf340 --- /dev/null +++ b/SH_PROJECTS/installzshyesorno.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# This script will ask you to install ZSH (Ubuntu/DEB/APT Only) +# Package : zsh, using variable. +# To make this script working fully, you need to run it as root. +# Read the script before if you are aware ! +pti=zsh +echo -n "Do you want to install Z-Shell ($pti)?(Y/n)" +read ask +if [[ $ask = [Yy] ]]; then + echo "Installing Z-Shell or ($pti)..." + apt install $pti &> /dev/null + echo "Finished, checking if the package is present..." + checkpkg=`which zsh` + if [[ $checkpkg = /usr/bin/zsh ]]; then + echo "Package present." + echo "Installation success" + elif [[ $checkpkg = * ]]; then + echo "Error !" + echo "Try to install manually" + fi +elif [[ $ask = [Nn] ]]; then + echo "Aborted." + exit +elif [[ $ask = * ]]; then + echo "Aborted." + exit +fi diff --git a/SH_PROJECTS/internetprocolmenu.sh b/SH_PROJECTS/internetprocolmenu.sh new file mode 100755 index 0000000..179c64d --- /dev/null +++ b/SH_PROJECTS/internetprocolmenu.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +ip4="inet " +ip6="inet6 " +eth="ether " +loop="loop " +printf ' +/----------------------------------\ +| INTERNET PROTOCOL MENU CHOOSER | +\----------------------------------/ +You can show IP Configuration +with this tool. Select your choice : + +0) Show INETv6 config +1) Show INETv4 config +2) Show ETH config +3) Show LOOP config +' +echo -n "Make your choice : " +read ask +if [[ $ask = 0 ]]; then + ip addr show primary | grep "inet6 " +elif [[ $ask = 1 ]]; then + ip addr show primary | grep "inet " +elif [[ $ask = 2 ]]; then + ip addr show primary | grep "ether " +elif [[ $ask = 3 ]]; then + ip addr show primary | grep "loopback" +elif [[ $ask = "" ]];then + echo "No input detected." + echo "Aborting!" + exit +elif [[ $ask = * ]]; then + echo "Incorrect value detected." + echo "Aborting!" + exit +fi \ No newline at end of file diff --git a/SH_PROJECTS/lscomplexorsimple.sh b/SH_PROJECTS/lscomplexorsimple.sh new file mode 100755 index 0000000..381638d --- /dev/null +++ b/SH_PROJECTS/lscomplexorsimple.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# This script will ask you for showing LS. but in different way, with -l, -la, and -x. +# -la will be shown "hidden " storage into lsh variable +# -l will be shown "complex" storage into lsc variable +# -x will be shown "simple " storage into lss variable +# Used variable : $lschoose, $lsh/c/s/n +lsh="ls -la" +lsc="ls -l" +lss="ls -x" +lsn="ls" +lschoose= +echo -n "Choose your LS, it will show the current directory (hidden,complex,simple): " +read lschoose +if [[ $lschoose = hidden ]]; then + $lsh ./ +elif [[ $lschoose = complex ]]; then + $lsc ./ +elif [[ $lschoose = simple ]]; then + $lss ./ +elif [[ $lschoose = * ]]; then + $lsn ./ +fi diff --git a/SH_PROJECTS/pingtester.sh b/SH_PROJECTS/pingtester.sh new file mode 100755 index 0000000..aa05608 --- /dev/null +++ b/SH_PROJECTS/pingtester.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# Using variables, manipulating Ping command. +local=127.0.0.1 +internetdns=8.8.8.8 +standardpriv=192.168.1.1 +altstd1=172.16.1.1 +altstd2=10.0.0.1 +altstd3=10.0.1.1 +custom=0.0.0.0 +ping= +printf ' +------------------------------ + PINGv4 TESTING MENU V1.0 +------------------------------ +Choose an ip address to test : + +local : Ping 127.0.0.1 loopback ip +internetdns : Ping Google DNS (8.8.8.8) for testing Internet Connection +standardpriv : Ping Home IP Modem (192.168.1.1) for testing home connection or company with this IP +altstd1 : Ping Alternative private IP (172.16.1.1) +altstd2 : Ping Alternative private IP (10.0.0.1) +altstd3 : Ping Alternative private IP (10.0.1.1)\n +manual : Ping Custom IP (XX.XX.XX.XX) +' +echo "Make your choice : " +read ping +if [[ $ping = local ]]; then + ping $local +elif [[ $ping = internetdns ]]; then + ping $internetdns +elif [[ $ping = standardpriv ]]; then + ping $standardpriv +elif [[ $ping = altstd1 ]]; then + ping $altstd1 +elif [[ $ping = altstd2 ]]; then + ping $altstd2 +elif [[ $ping = altstd3 ]]; then + ping $altstd3 +elif [[ $ping = manual ]]; then + echo -n "Enter IP : " + read custom + ping $custom 2> /dev/null +else + echo "Aborting!" + exit +fi diff --git a/SH_PROJECTS/showblkmenu.sh b/SH_PROJECTS/showblkmenu.sh new file mode 100755 index 0000000..6b697f0 --- /dev/null +++ b/SH_PROJECTS/showblkmenu.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +# This script will show a menu that allow user to show lsblk +# and ls /dev/ commands with filters. Using variables. +lsblk="lsblk" +lsblksd="ls /dev/sd*" +lsblktty="ls /dev/tty*" +lsblknvme="ls /dev/nvme*" +lsblkloop="ls /dev/loop*" +lsblkmem="ls /dev/mem*" +lsblkall="ls /dev/" +grepnvme= +grepsd= +blk= +clear +printf ' +--------------------- +BLK MENU CHOOSER v1.0 +--------------------- +This script menu show your current partitions, +virtual devices etc.. Into /dev/ +and lsblk command. + +Choose blk : + +1) list all partitions and disks +2) list all sd* devices in /dev/ (if exist) +3) list all tty* lines in /dev/ +4) list all nvme* devices in /dev/ (if exist) +5) list all loop virtual devices +6) list all mem devices in /dev/ +7) list everything in /dev/ +\n +' +echo -n "Make your choice (1/2/3/4/5/6/7/Abort) : " +read blk +if [[ $blk = 1 ]]; then + echo "Listing blk partitions..." + $lsblk 2> /dev/null +elif [[ $blk = 2 ]]; then + echo "Listing Special Devices into /dev !" + $lsblksd 2> /dev/null +elif [[ $blk = 3 ]]; then + echo "Listing TTY lines (in /dev/)" + $lsblktty 2> /dev/null +elif [[ $blk = 4 ]]; then + echo "Listing NVME devices in /dev/" + $lsblknvme 2> /dev/null +elif [[ $blk = 5 ]]; then + echo "Listing loop virtual devices" + $lsblkloop 2> /dev/null +elif [[ $blk = 6 ]]; then + echo "Listing memory device(s) into /dev/" + $lsblkmem 2> /dev/null +elif [[ $blk = 7 ]]; then + echo "Listing everything into /dev/" + $lsblkall 2> /dev/null +elif [[ =blk = * ]]; then + echo "Incorrect input / Empty input" + echo "Aborting!" + exit +elif [[ $blk = [Aa]bort ]]; then + echo "Aborting!" + exit +elif [[ -z "$blk" ]]; then + echo "Aborting!" + exit +fi +exit diff --git a/SH_PROJECTS/showsystemfilecat.sh b/SH_PROJECTS/showsystemfilecat.sh new file mode 100755 index 0000000..eb33f20 --- /dev/null +++ b/SH_PROJECTS/showsystemfilecat.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Allow user to show system files with a menu +catfstab="cat /etc/fstab" +cathostname="cat /etc/hostname" +cathosts="cat /etc/hosts" +choice= +printf ' +------------------------------------------ + SYSTEM CONFIG FILES MENU CHOOSER V1.0b +------------------------------------------ +This script will be updated with more features, +for now, you can : + +fstab : Show the fstab file +hostname : Show the hostname file +hosts : Show the hosts file + +' +echo -n "Make your choice : " +read choice +if [[ $choice = fstab ]]; then + $catfstab +elif [[ $choice = hostname ]]; then + $cathostname +elif [[ $choice = hosts ]]; then + $cathosts +else + echo "Aborting!" + exit +fi \ No newline at end of file diff --git a/SH_PROJECTS/sshclientmenu.sh b/SH_PROJECTS/sshclientmenu.sh new file mode 100755 index 0000000..9c36b3b --- /dev/null +++ b/SH_PROJECTS/sshclientmenu.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +# This script need espeak, you can install it : +# apt-get install espeak / yum install espeak +sship=0.0.0.0 +sshuser=user +sftpip=0.0.0.0 +sftpuser=user +mode=ssh + +printf ' +╔══════════════════════════╗ +║ Secure SHell Client Tool ║ +╚══════════════════════════╝ + +This tool allow you to connect +SSH Servers, SFTP Servers using +your own OpenSSH installation +(ssh/sftp command) + +You can run this tool as superuser +if **REALLY** needed. + +You need to run in ssh or sftp mode? + +1) ssh mode (Secure Shell Console) +2) sftp mode (Secure File Transfert Protocol) + +[1/2/Abort] +' +echo "Welcome" | espeak -venglish +echo +echo "Your hostname is `hostname`" +echo +echo -n "mode=" +read mode +if [[ $mode = 1 ]] +then + echo -n "Target IP : " + read sship + echo -n "Target Login : " + read sshuser + echo + printf ' +╔═══════════════════════════╗ +║ SSH STARTED LOGIN SESSION ║ +╚═══════════════════════════╝ + ' + echo "SSH Started Login Session" | espeak -venglish + echo + ssh $sship -l $sshuser 2> /dev/null + echo "Good Bye" | espeak -venglish +elif [[ $mode = 2 ]] +then + echo -n "Target IP : " + read sftpip + echo -n "Target Login : " + read sftpuser + echo + printf ' +╔════════════════════════════╗ +║ SFTP STARTED LOGIN SESSION ║ +╚════════════════════════════╝ + ' + echo "SFTP Started Login Session" | espeak -venglish + echo + sftp $sftpuser@$sftpip 2> /dev/null + echo "Connection Closed. Good Bye !" | espeak -venglish +fi \ No newline at end of file diff --git a/SH_PROJECTS/systeminfoshow.sh b/SH_PROJECTS/systeminfoshow.sh new file mode 100755 index 0000000..76ef8dd --- /dev/null +++ b/SH_PROJECTS/systeminfoshow.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +# This script will ask you for showing LS. but in different way, with -l, -la, and -x. +# Execute as root for more features ! +# Used variable : $lschoose, $ls* +lscpu="lscpu" +lshw="lshw" +lsmem="lsmem" +lsblk="lsblk" +lshwshort="lshw -short" +lshwmemory="lshw -short -c memory" +any="echo Aborting." +lschoose= +UID_CHECK=0 +printf ' +------------------------- + SYSTEM INFORMATION MENU +-------------------------\n +' +echo "Make your choice : " +echo -n " +0) processor : Show CPU informations +1) hardware : Full hardware informations +2) hardwareshort : Short but powerfull informations +3) memory : RAM informations +4) memory_root : RAM informations as root +5) sysmem : RAM Full informations +6) disks : Show partitions and disks\n + +Active User Informations : + +UID : $UID +User : $USER +Date : `date` + +Your choice [0/1/2/3/4/5/6/Abort] +" +read lschoose +if [[ $lschoose = 0 ]]; then + $lscpu +elif [[ $lschoose = 1 ]]; then + $lshw +elif [[ $lschoose = 2 ]]; then + $lshwshort +elif [[ $lschoose = 3 ]]; then + $lshwmemory 2> /dev/null +elif [[ $lschoose = 4 ]]; then + if [[ $UID = 0 ]]; then + $lshwmemory 2> /dev/null + elif [[ $UID = * ]]; then + echo " +You are not ROOT (your UID = $UID), if +you want to use this feature : + +run 'sudo ./[script.sh]' + +or + +run 'sudo su' and then run './[script.sh]' + " + exit + fi +elif [[ $lschoose = 5 ]]; then + $lsmem +elif [[ $lschoose = 6 ]]; then + $lsblk +elif [[ $lschoose = * ]]; then + $any +fi diff --git a/SH_PROJECTS/tracepathtester.sh b/SH_PROJECTS/tracepathtester.sh new file mode 100755 index 0000000..6567d0f --- /dev/null +++ b/SH_PROJECTS/tracepathtester.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Now, using Tracepath in the same way as Ping Tester : +local=127.0.0.1 +dns=8.8.8.8 +modemhome=192.168.1.1 +company1=172.16.1.1 +company2=10.0.1.1 +company3=10.0.0.1 +debug=0.0.0.0 +custom= +trace= +printf ' +------------------------------- + TRACEPATH MENU CHECKER V1.0 +------------------------------- +Choose a way to check Tracepath/route : + +local : Make a route to 127.0.0.1 (loopback/yourself) +dns : Make a route to 8.8.8.8 (Google DNS) +home : Make a route to 192.168.1.1 (Home Router or Company Router) +company1 : Make a route to 172.16.1.1 (Company network IP) +company2 : Make a route to 10.0.1.1 (Company network IP) +company3 : Make a route to 10.0.0.1 (Company network IP) + +custom : Make a route to custom IP (for Company with more IP or Home +with more than one Router) + +' +echo -n "Make your choice : " +read trace +if [[ $trace = local ]]; then + tracepath $local 2> /dev/null +elif [[ $trace = dns ]]; then + tracepath $dns 2> /dev/null +elif [[ $trace = home ]]; then + tracepath $modemhome 2> /dev/null +elif [[ $trace = company1 ]]; then + tracepath $company1 2> /dev/null +elif [[ $trace = company2 ]]; then + tracepath $company2 2> /dev/null +elif [[ $trace = company3 ]]; then + tracepath $company3 2> /dev/null +elif [[ $trace = custom ]]; then + echo "Enter IP : " + read $custom + tracepath $custom 2> /dev/null +else + echo "Aborting!" + exit +fi diff --git a/SH_TRAINING/training1.sh b/SH_TRAINING/training1.sh new file mode 100755 index 0000000..1b0af2b --- /dev/null +++ b/SH_TRAINING/training1.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +echo "Training Script. This script use only ECHO command" +# ----------------------------------- +num= +printf ' +If user send "One", the script answer "Two" +If user send "Two", the script answer "Three" +If user send "Three", the script answer "Four" +If user send "Four", the script answer "Five" +If any other input is sent, the script will answer "What?" + +Now, starting script ! +' +sleep 1 +echo -n "Enter a number in letter [One/Two/Three/Four]:" +read num +if [[ $num = [Oo]ne ]]; then + echo "Two" +elif [[ $num = [Tt]wo ]]; then + echo "Three" +elif [[ $num = [Tt]hree ]]; then + echo "Four" +elif [[ $num = [Ff]our ]]; then + echo "Five" +else + echo "What?" +fi \ No newline at end of file diff --git a/SH_TRAINING/training2.sh b/SH_TRAINING/training2.sh new file mode 100755 index 0000000..d963131 --- /dev/null +++ b/SH_TRAINING/training2.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +echo "Training Script. This script use only ECHO command" +# -----------------------------------7 +echo -n "What is your name ? " +read name +echo -n "What is you surname ? " +read surname +echo -n "How old are you ?" +read age +echo -n "Where do you live ?" +read live +printf ' +Emotions : + +------ +happy +sad +hungry +tired +angry +stressed +------ + +' +echo -n "What is your current emotion ?" +read emo +if [[ $emo = happy ]]; then + emotion=$emo +elif [[ $emo = sad ]]; then + emotion=$emo +elif [[ $emo = hungry ]]; then + emotion=$emo +elif [[ $emo = tired ]]; then + emotion=$emo +elif [[ $emo = angry ]]; then + emotion=$emo +elif [[ $emo = stressed ]]; then + emotion=$emo +else + emotion="without any emotions" +fi +echo "---------" +sleep 1 +clear +echo "Your name is $name" +echo "your surname is $surname" +echo "you are $age years old" +echo "Currently, you are $emo" +echo "and you live in $live" +echo +echo \ No newline at end of file diff --git a/SH_TRAINING/training3.sh b/SH_TRAINING/training3.sh new file mode 100755 index 0000000..f1f4381 --- /dev/null +++ b/SH_TRAINING/training3.sh @@ -0,0 +1,129 @@ +#!/usr/bin/env bash +echo "Training Script. This script use only ECHO command" +# -------------------------------------------------------------- +# In this script, user send five times a number between 1 and 5. +# Results can be : +# ⩇⩇ +# ⩇⩇⩇ +# ⩇⩇⩇⩇ +# ⩇⩇⩇⩇⩇ +# ⩇⩇⩇⩇⩇⩇ +# if user send 2 3 4 5 6 +# +# In case of inccorect imput into any variable, +# the value will be "invalid" +# -------------------------------------------------------------- +echo " + ⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺ +⎮ The Condition Game!⎮ + ⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺ + +This game will show line of '-' conditionnaly to +your choice of number. Example : + +2 ⩇⩇ +4 ⩇⩇⩇⩇ +5 ⩇⩇⩇⩇⩇ +1 ⩇ +3 ⩇⩇⩇ + +If you enter any other thing (like a word) it will show +'Value upper or equal of 6, or invalid input !' + +Enter five number, for example : +1 +2 +3 +4 +5 + +By typing enter for each number. + +-- +" +echo -n "one= " +read one +echo -n "two= " +read two +echo -n "three= " +read three +echo -n "four= " +read four +echo -n "five= " +read five +echo -- +echo "Choosen numbers : $one $two $three $four $five" +if [[ $one = 1 ]]; then + one=⩇ +elif [[ $one = 2 ]]; then + one=⩇⩇ +elif [[ $one = 3 ]]; then + one=⩇⩇⩇ +elif [[ $one = 4 ]]; then + one=⩇⩇⩇⩇ +elif [[ $one = 5 ]]; then + one=⩇⩇⩇⩇⩇ +else + one="Value $one is upper or equal of 6, or invalid input !" +fi +if [[ $two = 1 ]]; then + two=⩇ +elif [[ $two = 2 ]]; then + two=⩇⩇ +elif [[ $two = 3 ]]; then + two=⩇⩇⩇ +elif [[ $two = 4 ]]; then + two=⩇⩇⩇⩇ +elif [[ $two = 5 ]]; then + two=⩇⩇⩇⩇⩇ +else + two="Value $two is upper or equal of 6, or invalid input !" +fi +if [[ $three = 1 ]]; then + three=⩇ +elif [[ $three = 2 ]]; then + three=⩇⩇ +elif [[ $three = 3 ]]; then + three=⩇⩇⩇ +elif [[ $three = 4 ]]; then + three=⩇⩇⩇⩇ +elif [[ $three = 5 ]]; then + three=⩇⩇⩇⩇⩇ +else + three="Value $three is upper or equal of 6, or invalid input !" +fi +if [[ $four = 1 ]]; then + four=⩇ +elif [[ $four = 2 ]]; then + four=⩇⩇ +elif [[ $four = 3 ]]; then + four=⩇⩇⩇ +elif [[ $four = 4 ]]; then + four=⩇⩇⩇⩇ +elif [[ $four = 5 ]]; then + four=⩇⩇⩇⩇⩇ +else + four="Value $four is upper or equal of 6, or invalid input !" +fi +if [[ $five = 1 ]]; then + five=⩇ +elif [[ $five = 2 ]]; then + five=⩇⩇ +elif [[ $five = 3 ]]; then + five=⩇⩇⩇ +elif [[ $five = 4 ]]; then + five=⩇⩇⩇⩇ +elif [[ $five = 5 ]]; then + five=⩇⩇⩇⩇⩇ +else + five="Value $five is upper or equal of 6, or invalid input !" +fi +echo "Now, this is the result : + +$one +$two +$three +$four +$five + +" \ No newline at end of file diff --git a/SH_TRAINING/training4.sh b/SH_TRAINING/training4.sh new file mode 100755 index 0000000..6460380 --- /dev/null +++ b/SH_TRAINING/training4.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +echo " +---------------------- + The additions script +---------------------- +" +echo +echo "Enter two value, the script will calculate them." +echo +echo -n "First : " + read first +echo -n "$first+" + read second +echo "$first+$second=`echo $(($first+$second))`" +echo "$first plus $second equal to `echo $(($first+$second))`" +echo +echo "Now, the same thing with substracting :" +echo -n "First : " +read first +echo -n "$first-" +read second +echo "$first-$second=`echo $(($first-$second))`" +echo "$first substracted to $second equal to `echo $(($first-$second))`" +echo +echo "Now, with dividing :" +echo +echo -n "First : " +read first +echo -n "$first/" +read second +echo "$first/$second=`echo $(($first/$second))`" +echo "$first divided $second equal to `echo $(($first/$second))`" +echo +echo "Now, with... Multiplication !" +echo +echo -n "First : " +read first +echo -n "$first*" +read second +echo "$first*$second=`echo $(($first*$second))`" +echo "$first multiplicated by $second equal to `echo $(($first*$second))`" +echo +echo "End of script" \ No newline at end of file diff --git a/SH_TUTOS/Les_conditions.md b/SH_TUTOS/Les_conditions.md new file mode 100644 index 0000000..dc2adec --- /dev/null +++ b/SH_TUTOS/Les_conditions.md @@ -0,0 +1,62 @@ +# This is not a script + +Les conditions dans un script shell type BASH et SH (qui ne sont pas pareil !) permettent de faire un choix en fonction d'un résultat de variable (par exemple, la réponse de l'utilisateur) + +Ainsi, avec la condition suivante : + + +------------------------------------ +echo -n "Choose between A, B or C :" +read answer +if [[ $answer = A ]] +then + echo "Is A letter" +elif [[ $answer = B ]] +then + echo "Is B letter" +elif [[ $answer = C ]] +then + echo "Is C letter" +fi +------------------------------------ + +La condition va alors : + +Répondre "Is A letter" si l'utilisateur insère "A" " +Répondre "Is B letter" si l'utilisateur insère "B" " +Répondre "Is C letter" si l'utilisateur insère "C" " + +Ainsi, imaginez que cette condition génére autre chose que des commandes echo, vous pourrez ainsi afficher des menus, installer des paquets, faire des pings, faire des logs, et plus encore ! + + +------------------------------------------------------------------ +La différence entre BASH et SH est simple au niveau des conditions + +En effet, le SH (Shell) étant plus vieux que le BASH (Bourne Again Shell) il existe une différence de scripting au niveau des conditions. + +En #!/bin/sh, on mettra alors : + +if [ conditions ] +then + +En #!/bin/bash, on mettra alors : + +if [[ conditions ]] +then + +Le SH ne supporte pas les double "[]" par exemple. + +------------------------------------------------------------------ +Le then, en fonction de votre Shell (bash, zsh...) le then peut se +positionner de deux façon : + +if [[ conditions ]]; then + +et + +if [[ conditions ]] +then + +Il est libre de choisir entre l'un et l'autre, en prenant en +compte que le deuxiéme est plus sûr. + diff --git a/TIPS.md b/TIPS.md new file mode 100755 index 0000000..085cba9 --- /dev/null +++ b/TIPS.md @@ -0,0 +1,13 @@ +Vous pouvez utiliser cette astuce pour voir les commandes des scripts lors de son execution : + +faire : + +bash [script] + +execute le script normalement. + +faire : + +bash -xv [script] + +execute le script en debugging (avec les commandes) diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..95da5ae --- /dev/null +++ b/test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +echo "On commence" +echo +echo -n "Entrer la lettre A, B ou C : " +read var +if [[ $var = A ]] +then + echo A +elif [[ $var = B ]] +then + echo B +elif [[ $var = C ]] +then + echo C +elif [[ $var = "" ]] +then + echo "empty input" +elif [[ $var = * ]]; then + echo "$var is incorrect" +fi