Last active
August 26, 2021 07:03
-
-
Save renekreijveld/a904fb36f24c70aed7a919c0a82065c0 to your computer and use it in GitHub Desktop.
Bash script to cleanup all Joomla files and folders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# cleanjoomla -- Script to delete all Joomla files and folders | |
# | |
# This scripts supports Joomla versions 2.5 - 3.x | |
# | |
# Copyright 2021 Rene Kreijveld - [email protected] | |
# This program is free software; you may redistribute it and/or modify it. | |
# | |
# Version history | |
# 1.0 Initial version | |
# 1.1 Added report option | |
# general variables | |
mypath=$(cd $(dirname ${0}); pwd -P) | |
myname=$(basename ${0}) | |
# version | |
version=1.1 | |
# show message function | |
showmessage() | |
{ | |
if [ "${silent}" == "no" ] | |
then | |
echo "$1" | |
fi | |
} | |
# display usage information | |
usage() { | |
echo "" | |
echo "${myname} version ${version}, written by Rene Kreijveld." | |
echo "" | |
echo "Usage: ${myname} [-r] [-s] [-h]" | |
echo "" | |
echo "-r Report. Show all files and folders being deleted." | |
echo "-s Silent. No progress messages will be shown." | |
echo "-h Help. Display this info." | |
echo "" | |
exit 0 | |
} | |
# process the arguments | |
silent="no" | |
report="no" | |
while getopts sh opt | |
do | |
case "${opt}" in | |
r) report="yes" | |
;; | |
s) silent="yes" | |
;; | |
h) usage | |
;; | |
\?) echo "Invalid option: -$OPTARG" >&2 | |
exit 1 | |
;; | |
:) echo "Option -$OPTARG requires an argument." >&2 | |
exit 1 | |
;; | |
esac | |
done | |
showmessage "${myname} version ${version}, written by Rene Kreijveld." | |
# Cleanup Joomla folders | |
showmessage "Deleting Joomla folders..." | |
for folder in administrator bin cache cli components images includes installation language layouts libraries logs media modules plugins templates templates tmp | |
do | |
if [ -d ${folder} ]; then | |
if [ "${report}" == "no" ] | |
then | |
echo ${folder} | |
fi | |
rm -rf ${folder} | |
fi | |
done | |
# Cleanup Joomla files | |
showmessage "Deleting Joomla files..." | |
for file in .htaccess configuration.php htaccess.txt index.php joomla.xml LICENSE.txt README.txt robots.txt robots.txt.dist web.config.txt | |
do | |
if [ -f ${file} ]; then | |
if [ "${report}" == "no" ] | |
then | |
echo ${file} | |
fi | |
rm -f ${file} | |
fi | |
done | |
# list leftovers | |
if [ "${silent}" == "no" ] | |
then | |
showmessage "Cleanup finished, these files and folders are still left:" | |
ls -la | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment