-
Notifications
You must be signed in to change notification settings - Fork 3
/
plesk_generate.sh
56 lines (45 loc) · 1.44 KB
/
plesk_generate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Initialize domain variable
server_domain=""
# Function to display usage information
usage() {
echo "Usage: $0 [-d <domain_name>] [-h]" 1>&2
exit 1
}
# Parse command line options
while getopts ":d:h" opt; do
case $opt in
d)
server_domain="$OPTARG"
;;
h)
usage
;;
*)
usage
;;
esac
done
# Prompt for domain name if not provided as an option
if [ -z "$server_domain" ]; then
read -p "Enter server domain: " server_domain
fi
# Check if domain name is still empty
if [ -z "$server_domain" ]; then
echo "Error: Domain name is required." >&2
usage
fi
echo -e "\n# open restriction"
echo -e "plesk bin poweruser --off -lock false"
echo -e "plesk bin poweruser --on -simple false -lock false"
echo -e "\n# Backup Plesk sys db"
echo -e "plesk db dump psa > C:\psa_dump.sql\n\n"
echo -e "# Make admin owner of all subscriptions "
echo -e "foreach (\$subscription in plesk bin subscription --list) {plesk bin subscription --change-owner \$subscription -owner admin}\n\n"
# Generate a random password
password=$(openssl rand -base64 18)
echo -e "# Create a new end client user"
short_hostname=$(echo "$server_domain" | cut -d'.' -f1)
username="${short_hostname}n"
email="${username}@${server_domain}"
echo -e "plesk bin user --create \"$username\" -owner admin -passwd \"$password\" -cname \"$username\" -email \"$email\" -role webmaster\n\n"