Skip to content

Commit f71fb97

Browse files
WordPress-WooCommerce latest script changes
1 parent 13e4765 commit f71fb97

File tree

3 files changed

+88
-11
lines changed

3 files changed

+88
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
3+
RED='\033[1;31m'
4+
NC='\033[0m'
5+
6+
echo -e "${RED}
7+
################################################################################################################
8+
# Your MarketPlace App has been deployed successfully! #
9+
# Passwords are stored under /root/ #
10+
# Please spend 2 minutes for configuration #
11+
# Kindly update the below configuration to complete the setup #
12+
################################################################################################################
13+
${NC}"
14+
15+
echo
16+
echo -e "${RED}This message will be removed in the next login!${NC}"
17+
echo
18+
echo
19+
echo -e "${RED}Use the Below Password for logging into MySQL${NC}"
20+
echo
21+
cat /root/.mysql_root_password
22+
echo
23+
echo -e "${RED}Use the Below Password for logging into Phpmyadmin${NC}"
24+
echo
25+
cat /root/.phpmyadmin_password
26+
echo
27+
echo -e "${RED}Refer to the below wordpress database login details${NC}"
28+
echo
29+
cat /root/.wordpress_database_details
30+
echo
31+
32+
# WordPress Salts
33+
for i in `seq 1 8`
34+
do
35+
wp_salt=$(</dev/urandom tr -dc 'a-zA-Z0-9!@#$%^&*()\-_ []{}<>~`+=,.;:/?|' | head -c 64 | sed -e 's/[\/&]/\\&/g')
36+
sed -e "0,/put your unique phrase here/s/put your unique phrase here/${wp_salt}/" \
37+
-i /var/www/html/wp-config.php;
38+
done
39+
40+
#Cleanup script
41+
rm -rf /usr/local/src/
42+
mkdir -p /usr/local/src/
43+
rm -rf /var/lib/cloud/instances/*
44+
rm -rf /var/lib/cloud/data/*
45+
find /var/log -mtime -1 -type f -exec truncate -s 0 {} \;
46+
rm -rf /var/log/*.gz /var/log/*.[0-9] /var/log/*-????????
47+
cat /dev/null > /var/log/lastlog; cat /dev/null > /var/log/wtmp
48+
apt-get -y autoremove >/dev/null 2>&1
49+
apt-get -y autoclean >/dev/null 2>&1
50+
history -c
51+
cat /dev/null > /root/.bash_history
52+
unset HISTFILE
53+
54+
#To replace the Domain Name in the apache configuration
55+
a=0
56+
while [ $a -eq 0 ]
57+
do
58+
echo -e "${RED}To cancel setup, press Ctrl+C. This script will run again on your next login:${NC}"
59+
echo -e "${RED}Enter the domain name for your new WordPress site:${NC}"
60+
echo -e "${RED}(ex. example.org or test.example.org) do not include www or http/s:${NC}"
61+
read -p "Domain/Subdomain name: " dom
62+
if [ -z "$dom" ]
63+
then
64+
a=0
65+
echo -e "${RED}Please provide a valid domain or subdomain name to continue to press Ctrl+C to cancel${NC}"
66+
else
67+
a=1
68+
fi
69+
done
70+
71+
sed -i "s/\$domain/$dom/g" /etc/apache2/sites-available/001-default.conf
72+
73+
a2enconf block-xmlrpc >/dev/null 2>&1
74+
75+
wp plugin install smartarget-contact-us --activate --allow-root --path="/var/www/html"
76+
wp plugin install woocommerce --activate --allow-root --path="/var/www/html"
77+
wp plugin install wp-fail2ban --allow-root --path="/var/www/html"
78+
wp plugin activate wp-fail2ban --allow-root --path="/var/www/html"
79+
80+
chown -Rf www-data.www-data /var/www/
81+
82+
systemctl restart apache2
83+
84+
rm -rf /root/.bashrc
85+
cp /etc/skel/.bashrc /root

wordpress-woocommerce-20-04/woocommerce.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ cd /usr/local/src/wordpress-woocommerce-20-04/etc/apache2/conf-enabled/ && wget
1414

1515
cd /usr/local/src/wordpress-woocommerce-20-04/usr/share/phpmyadmin/ && wget https://raw.githubusercontent.com/stackbill/marketplace/main/_common-files/usr/share/phpmyadmin/.htaccess
1616

17-
cd /usr/local/src/wordpress-woocommerce-20-04/opt/cloudstack/ && wget https://raw.githubusercontent.com/stackbill/marketplace/main/_common-files/opt/cloudstack/wp-setup.sh
17+
cd /usr/local/src/wordpress-woocommerce-20-04/opt/cloudstack/ && wget https://raw.githubusercontent.com/stackbill/marketplace/main/_common-files/opt/cloudstack/woocommerce-cleanup.sh
1818

1919
cd /usr/local/src/wordpress-woocommerce-20-04/ && wget https://raw.githubusercontent.com/stackbill/marketplace/main/wordpress-woocommerce-20-04/woocommerce.yaml

wordpress-woocommerce-20-04/woocommerce.yaml

+2-10
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,6 @@
297297
dest: /usr/bin/wp
298298
mode: '0755'
299299

300-
- name: Installating fail2ban and Woocommerce
301-
shell: "{{ item }}"
302-
with_items:
303-
- wp plugin install smartarget-contact-us --activate --allow-root --path="/var/www/html"
304-
- wp plugin install woocommerce --activate --allow-root --path="/var/www/html"
305-
- wp plugin install wp-fail2ban --allow-root --path="/var/www/html"
306-
- wp plugin activate wp-fail2ban --allow-root --path="/var/www/html"
307-
308300
- name: Installing postfix
309301
apt:
310302
name: [ 'postfix' , 'mailutils' ]
@@ -320,12 +312,12 @@
320312
src: "{{ item.confsrc }}"
321313
dest: "{{ item.confdest }}"
322314
with_items:
323-
- { confsrc: '/usr/local/src/wordpress-woocommerce-20-04/opt/cloudstack/wp-setup.sh', confdest: '/opt/cloudstack/'}
315+
- { confsrc: '/usr/local/src/wordpress-woocommerce-20-04/opt/cloudstack/woocommerce-cleanup.sh', confdest: '/opt/cloudstack/'}
324316

325317
- name: Adding a line for shell script
326318
lineinfile:
327319
path: /root/.bashrc
328-
line: "chmod +x /opt/cloudstack/wp-setup.sh && /opt/cloudstack/wp-setup.sh"
320+
line: "chmod +x /opt/cloudstack/woocommerce-cleanup.sh && /opt/cloudstack/woocommerce-cleanup.sh"
329321
state: present
330322

331323
- name: Restarting sshd

0 commit comments

Comments
 (0)