Created
September 26, 2021 14:00
-
-
Save Iranon/701272da8e78a9d8522a7f6c5e2dcfb2 to your computer and use it in GitHub Desktop.
A shell script to copy your php scripts (file or folder) into the www/html directory (httpd.service)
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 | |
#- CopyToHTTPD | |
#|-- Matteo Vinci [Iranon] (c) 2021 --| | |
#Text Colors | |
RED='\033[0;31m'; | |
NOCOLOR='\033[0m'; | |
#File | |
if [[ -f $1 ]]; then | |
echo "------------" | |
echo "|-> File <-|" | |
echo "------------" | |
tf=/var/www/html/index.php; #target-file | |
if sudo cp $1 $tf; then | |
echo "- copied -" | |
if sudo chown apache:apache $tf; then | |
sudo chcon -t httpd_sys_content_t $tf #change SELinux context | |
echo -e "- configured -\n" | |
exit 0; | |
else | |
echo -e "${RED}- ERROR::CONFIGURING -${NOCOLOR}\n" | |
exit 2; | |
fi | |
else | |
echo -e "${RED}- ERROR::COPYING -${NOCOLOR}\n" | |
exit 1; | |
fi | |
#Directory | |
elif [[ -d $1 ]]; then | |
echo "-----------------" | |
echo "|-> Directory <-|" | |
echo "-----------------" | |
td=/var/www/html; | |
if sudo cp -TR $1 $td/$1; then | |
echo "- copied -" | |
if sudo chown -R apache:apache $td/$1; then | |
sudo chcon -R -t httpd_sys_content_t $td/$1 #change SELinux context | |
echo -e "- configured -\n" | |
exit 0; | |
else | |
echo -e "${RED}- ERROR::CONFIGURING -${NOCOLOR}\n" | |
exit 2; | |
fi | |
else | |
echo -e "${RED}- ERROR::COPYING -${NOCOLOR}\n" | |
exit 1; | |
fi | |
fi | |
#Existence | |
if ! [[ -e $1 ]]; then | |
echo -e "\n- NOT FOUND -\n"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment