diff --git a/fix.sh b/fix.sh index a682131..bb60616 100644 --- a/fix.sh +++ b/fix.sh @@ -299,8 +299,8 @@ function func_php_mails { function func_backup_question { echo -ne "\n${PURPLE}Do you want to make files and database backup (y/n)?${NC} "; read -r answer case ${answer:0:1} in y|Y ) - username=$(echo "$cwd" | awk -F[/:] '{ print $3 }') # DONE: read username from `id` - dirs=(/home/"${username}"/domains/*/public_html) # DONE: read list of dirs in $HOME/domains/ and show select options + username=$(echo "$cwd" | awk -F[/:] '{ print $3 }') + dirs=(/home/"${username}"/domains/*/public_html) read -p "$( f=0 for dirname in "${dirs[@]}" ; do @@ -314,24 +314,23 @@ function func_backup_question { echo -e "\n${BYELLOW}Preparing files backup in /home/${username}/ folder.${NC}" # cd /home/${username}/ && backup=FILES_BACKUP_${DATE}_${domain_name} && mkdir $backup && cp -r ${selected_dir}/* /home/${username}/$backup - # CHANGE gix.sh TO fix.sh LATER ON !!!!!!! cd /home/"${username}"/ && backup=FILES_BACKUP_${DATE}_${domain_name} && mkdir "$backup" && rsync -a "${selected_dir}"/* /home/"${username}"/"$backup" --exclude="fix.sh" echo -e "${CHECK} ${GREEN}Prepared.${NC}\n" - if [[ -d ${selected_dir}/wp-content ]] # DONE: if WP - read from wp-config.php + if [[ -d ${selected_dir}/wp-content ]] then WPDBNAME=$(cat "${selected_dir}"/wp-config.php | grep DB_NAME | cut -d \' -f 4) WPDBUSER=$(cat "${selected_dir}"/wp-config.php | grep DB_USER | cut -d \' -f 4) WPDBPASS=$(cat "${selected_dir}"/wp-config.php | grep DB_PASSWORD | cut -d \' -f 4) echo -e "${BYELLOW}Preparing WordPress databse (${WPDBNAME}) backup in /home/${username}/ folder.${NC}" db_backup=DB_BACKUP_${DATE}_${WPDBNAME} && mkdir "$db_backup" && mysqldump -u "${WPDBUSER}" -p"${WPDBPASS}" "${WPDBNAME}" > /home/"${username}"/"${db_backup}"/"${WPDBNAME}".sql - # db_backup=DB_BACKUP_${DATE}_${WPDBNAME} && mkdir "$db_backup" && mysqldump -u "${WPDBUSER}" -p"${WPDBPASS}" "${WPDBNAME}" | gzip > /home/"${username}"/"${db_backup}"/"${WPDBNAME}".gz # DONE: use gzip `mysqldump ... | gzip > file.gz` - saves space and speeds up dumping + # db_backup=DB_BACKUP_${DATE}_${WPDBNAME} && mkdir "$db_backup" && mysqldump -u "${WPDBUSER}" -p"${WPDBPASS}" "${WPDBNAME}" | gzip > /home/"${username}"/"${db_backup}"/"${WPDBNAME}".gz else echo -ne "${PURPLE}Enter clients MySQL Database Name: ${NC}"; read -r db_name echo -ne "${PURPLE}Enter clients MySQL Database Username: ${NC}"; read -r db_username echo -ne "${PURPLE}Enter clients MySQL Database password: ${NC}"; read -sr db_password echo -e "${BYELLOW}Preparing database backup in /home/${username}/ folder.${NC}" db_backup=DB_BACKUP_${DATE}_${db_name} && mkdir "$db_backup" && mysqldump -u "${db_username}" -p"${db_password}" "${db_name}" > /home/"${username}"/"${db_backup}"/"${db_name}".sql - # db_backup=DB_BACKUP_${DATE}_${db_name} && mkdir "$db_backup" && mysqldump -u "${db_username}" -p"${db_password}" "${db_name}" | gzip > /home/"${username}"/"${db_backup}"/"${db_name}".gz # DONE: use gzip `mysqldump ... | gzip > file.gz` - saves space and speeds up dumping + # db_backup=DB_BACKUP_${DATE}_${db_name} && mkdir "$db_backup" && mysqldump -u "${db_username}" -p"${db_password}" "${db_name}" | gzip > /home/"${username}"/"${db_backup}"/"${db_name}".gz fi cd "$cwd" echo -e "${CHECK} ${GREEN}Prepared.${NC}\n" @@ -344,8 +343,8 @@ function func_backup_question { function func_domain_selection { cwd=$(pwd) - username=$(echo "$cwd" | awk -F[/:] '{ print $3 }') # DONE: read username from `id` - dirs=(/home/"${username}"/domains/*/public_html) # DONE: read list of dirs in $HOME/domains/ and show select options + username=$(echo "$cwd" | awk -F[/:] '{ print $3 }') + dirs=(/home/"${username}"/domains/*/public_html) read -p "$( f=0 for dirname in "${dirs[@]}" ; do @@ -480,7 +479,7 @@ function func_malware_fix () { WPTABLEPREFIX=$(cat wp-config.php | grep "\$table_prefix" | cut -d \' -f 2) # generates a default wp-config.php - mv wp-config.php wp-config.php-OLD-DISABLED && wget -c https://fix.lukasba.com/wp-config.txt -O wp-config.php + mv wp-config.php wp-config.php-OLD-DISABLED && wget -c https://brmb.org/wp-fix/wp-config.txt -O wp-config.php # fills in the correct DB credentials on the new wp-config.php file sed -i "/DB_NAME/s/'[^']*'/'${WPDBNAME}'/2" wp-config.php @@ -501,7 +500,7 @@ function func_malware_fix () { for i in $(wp theme list --skip-themes --skip-plugins --fields=name | grep -v '^name'); do echo -e "-----\n$i\n-----"; wp theme install --skip-themes --skip-plugins --force "$i" --version="$(wp theme list --skip-themes --skip-plugins --name="$i" --fields=version | grep -v '^version')"; done echo -e "\n${YELLOW}Replacing current .htaccess with the default WordPress .htaccess..${NC}" - mv .htaccess .htaccess-OLD-DISABLED && wget -c https://fix.lukasba.com/htaccess.txt -O .htaccess + mv .htaccess .htaccess-OLD-DISABLED && wget -c https://brmb.org/wp-fix/wp-config.txt -O .htaccess echo -e "\n${YELLOW}Disabling .htaccess files in main folders..${NC}" mv /wp-admin/.htaccess /wp-admin/.htaccess-OLD-DISABLED && mv /wp-content/.htaccess /wp-content/.htaccess-OLD-DISABLED && mv /wp-includes/.htaccess /wp-includes/.htaccess-OLD-DISABLED echo -e "\n${YELLOW}Deleting .php files in /uploads/ folder..${NC}" @@ -543,7 +542,7 @@ function func_malware_fix () { WPTABLEPREFIX=$(cat wp-config.php | grep "\$table_prefix" | cut -d \' -f 2) # generates a default wp-config.php - mv wp-config.php wp-config.php-OLD-DISABLED && wget -c https://fix.lukasba.com/wp-config.txt -O wp-config.php + mv wp-config.php wp-config.php-OLD-DISABLED && wget -c https://brmb.org/wp-fix/wp-config.txt -O wp-config.php # fills in the correct DB credentials on the new wp-config.php file sed -i "/DB_NAME/s/'[^']*'/'${WPDBNAME}'/2" wp-config.php @@ -574,13 +573,13 @@ function func_malware_fix () { for i in $(wp theme list --skip-themes --skip-plugins --fields=name | grep -v '^name'); do echo -e "-----\n$i\n-----"; wp theme install --skip-themes --skip-plugins --force "$i" --version="$(wp theme list --skip-themes --skip-plugins --name="$i" --fields=version | grep -v '^version')"; done echo -e "\n${YELLOW}Replacing current .htaccess with the default WordPress .htaccess..${NC}" - mv .htaccess .htaccess-OLD-DISABLED && wget -c https://fix.lukasba.com/htaccess.txt -O .htaccess + mv .htaccess .htaccess-OLD-DISABLED && wget -c https://brmb.org/wp-fix/htaccess.txt -O .htaccess echo -e "\n${YELLOW}Disabling .htaccess files in main folders..${NC}" mv /wp-admin/.htaccess /wp-admin/.htaccess-OLD-DISABLED && mv /wp-content/.htaccess /wp-content/.htaccess-OLD-DISABLED && mv /wp-includes/.htaccess /wp-includes/.htaccess-OLD-DISABLED echo -e "\n${YELLOW}Deleting .php files in /uploads/ folder..${NC}" find wp-content/uploads/ -type f -name "*.php" -delete - cd wp-content/uploads/ && wget -c https://fix.lukasba.com/htaccess-php.txt -O .htaccess ; cd "${cwd}" || exit - cd wp-includes/ && wget -c https://fix.lukasba.com/htaccess-php.txt -O .htaccess ; cd "${cwd}" || exit + cd wp-content/uploads/ && wget -c https://brmb.org/wp-fix/htaccess-php.txt -O .htaccess ; cd "${cwd}" || exit + cd wp-includes/ && wget -c https://brmb.org/wp-fix/htaccess-php.txt -O .htaccess ; cd "${cwd}" || exit echo -e "\n${YELLOW}Fixing permissions for files and folders..${NC}" # file and folder permissions reset to Hostinger defaults