-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmagento24_env_switch.sh
More file actions
executable file
·46 lines (41 loc) · 1.04 KB
/
magento24_env_switch.sh
File metadata and controls
executable file
·46 lines (41 loc) · 1.04 KB
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
#!/bin/bash
function switch_php() {
if [ "$1" == "7.3" ]; then
sudo update-alternatives --set php /usr/bin/php7.3
elif [ "$1" == "8.1" ]; then
sudo update-alternatives --set php /usr/bin/php8.1
else
echo "Invalid PHP version. Supported versions: 7.3, 8.1"
fi
}
function switch_composer() {
if [ "$1" == "1" ]; then
sudo composer self-update --1
elif [ "$1" == "2" ]; then
sudo composer self-update --2
else
echo "Invalid Composer version. Supported versions: 1, 2"
fi
}
function switch_apache() {
if [ "$1" == "7.3" ]; then
sudo a2dismod php8.1
sudo a2enmod php7.3
sudo systemctl restart apache2
elif [ "$1" == "8.1" ]; then
sudo a2dismod php7.3
sudo a2enmod php8.1
sudo systemctl restart apache2
else
echo "Invalid PHP version. Supported versions: 7.3, 8.1"
fi
}
if [ "$1" == "php" ]; then
switch_php "$2"
elif [ "$1" == "composer" ]; then
switch_composer "$2"
elif [ "$1" == "apache" ]; then
switch_apache "$2"
else
echo "Usage: $0 [php|composer|apache] [7.3|8.1|1|2]"
fi