File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
echo " Installing Flarum..."
4
4
5
+ # Trap errors
6
+ trap ' echo "An error occurred. Exiting..." && rollback && exit 1' ERR
7
+
5
8
# Prepare installation inputs
6
9
cat << EOF > install.yml
7
10
debug: true
@@ -34,6 +37,8 @@ if [ -d "../framework" ]; then
34
37
35
38
# Set minimum-stability to dev
36
39
composer config minimum-stability dev
40
+ # Set prefer-stable to true
41
+ composer config prefer-stable true
37
42
fi
38
43
39
44
# Download dependencies
@@ -47,3 +52,28 @@ rm install.yml
47
52
48
53
# Replace config.php with .config.php to always use the environment variables
49
54
cp .config.php config.php
55
+
56
+ # Undo trap
57
+ trap - ERR
58
+
59
+ echo " Flarum installed successfully!"
60
+
61
+ # A function to revert all changes made by this script
62
+ function rollback() {
63
+ # Move the config.php back
64
+ mv config.php .config.php
65
+
66
+ # Undo composer install
67
+ rm -rf vendor
68
+ rm composer.lock
69
+
70
+ # Undo the workbench
71
+ studio unload " ../workbench/*"
72
+
73
+ # Undo the framework
74
+ if [ -d " ../framework" ]; then
75
+ studio unload " ../framework/framework/*"
76
+ studio unload " ../framework/extensions/*"
77
+ studio unload " ../framework/php-packages/*"
78
+ fi
79
+ }
You can’t perform that action at this time.
0 commit comments