Skip to content

Commit 06927dc

Browse files
committed
feat: maybe functional??
1 parent 425b373 commit 06927dc

File tree

4 files changed

+94
-43
lines changed

4 files changed

+94
-43
lines changed

blueprint.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ if [[ $1 != "-bash" ]]; then
255255
echo -e "\x1b[30;41;1m YOU ARE USING THE LEGACY UPDATER!! \x1b[0m"
256256
echo -e "\n\x1b[31;49;1mPlease rerun 'blueprint -upgrade' to continue the update process. This is NOT A BUG.\nPress ENTER to continue back to legacy updater (will fail) or ^C to terminate the process.\x1b[0m"
257257

258-
echo -e "\n1. Terminate this process with CTRL+C (^C)"
259-
echo -e "2. Run 'blueprint -upgrade'"
260-
echo -e "3. Blueprint will update to the latest version."
258+
echo -e "\n\x1b[31;49m1. Terminate this process with CTRL+C (^C)\x1b[0m"
259+
echo -e "\n\x1b[31;49m2. Run 'blueprint -upgrade'\x1b[0m"
260+
echo -e "\n\x1b[31;49m3. Blueprint will update to the latest version.\x1b[0m"
261261

262262
read -r
263263
exit 1

scripts/commands/advanced/upgrade.sh

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,35 @@ Command() {
1212
update_choice=""
1313

1414
# Initial steps count for progress bar
15-
export PROGRESS_TOTAL=10
15+
export PROGRESS_TOTAL=7
1616
export PROGRESS_NOW=0
1717

1818
# Make sure the script is in $FOLDER
1919
cd "$FOLDER" || exit 1
2020

21+
# Export the repository variables
22+
export remote_repo
23+
export remote_branch
24+
export fetched_version
25+
2126
# Create temporary directory for upgrade files
2227
PRINT INFO "Creating .update directory.."
2328
mkdir -p .update
2429

25-
# Define cleanup for this step
30+
# Define cleanup
2631
cleanup() {
32+
PRINT INFO "Cleaning up.."
2733
cd "$FOLDER" || exit 1
34+
35+
if [[ $development_files == true ]]; then
36+
PRINT INFO "Restoring extension development files.."
37+
rm -rf .blueprint/dev
38+
mv .update/backup/dev .blueprint/dev
39+
fi
2840
rm -rf .update
2941

3042
if [[ $1 != "" ]]; then
43+
hide_progress
3144
exit "$1"
3245
fi
3346
}
@@ -83,12 +96,23 @@ Command() {
8396
esac
8497
else
8598
PRINT DEBUG "\$1 was NOT 'remote' (it was '$1')"
99+
PRINT INFO "Fetching version info"
100+
101+
php artisan bp:version:cache 2> $BLUEPRINT__DEBUG
102+
tag_latest=$(php artisan bp:version:latest)
103+
PRINT DEBUG "tag_latest is $tag_latest"
104+
105+
fetched_version="$tag_latest"
106+
remote_repo="https://github.com/$REPOSITORY.git"
107+
remote_branch="release/$tag_latest"
108+
PRINT DEBUG "set remote_repo to '$remote_repo', remote_branch to '$remote_branch'"
86109
fi
87110

88111
((PROGRESS_NOW++))
89112

90113
# Fetching repository with git
91114
PRINT INFO "Downloading repository.."
115+
hide_progress
92116
git clone "$remote_repo" .update/repo --branch "$remote_branch"
93117

94118
if [[ ! -d ".update/repo" ]]; then
@@ -98,7 +122,60 @@ Command() {
98122

99123
((PROGRESS_NOW++))
100124

125+
# Determine and backup development files
126+
development_files=false
127+
if [[ -n $(find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ]]; then
128+
development_files=true
129+
PRINT INFO "Backing up extension development files.."
130+
mkdir -p .update/backup
131+
cp -Rf .blueprint/dev .update/backup/dev
132+
fi
133+
134+
((PROGRESS_NOW++))
135+
136+
# Delete files
137+
PRINT INFO "Deleting files.."
138+
rm -rf .blueprint
139+
140+
# Clean up folders with potentially broken symlinks.
141+
rm \
142+
"resources/views/blueprint/admin/wrappers/"* \
143+
"resources/views/blueprint/dashboard/wrappers/"* \
144+
"routes/blueprint/application/"* \
145+
"routes/blueprint/client/"* \
146+
"routes/blueprint/web/"* \
147+
&>> /dev/null # cannot forward to debug dir because it does not exist
148+
149+
((PROGRESS_NOW++))
150+
101151
# Run update script
102152
PRINT INFO "Running update script.."
103-
bash .update/repo
153+
source .update/repo/scripts/updater/update.sh
154+
hide_progress
155+
UpdaterInstall
156+
157+
((PROGRESS_NOW++))
158+
159+
# Deprecated, kept in for backwards compatibility
160+
sed -i -E \
161+
-e "s|OWNERSHIP=\"www-data:www-data\" #;|OWNERSHIP=\"$OWNERSHIP\" #;|g" \
162+
-e "s|WEBUSER=\"www-data\" #;|WEBUSER=\"$WEBUSER\" #;|g" \
163+
-e "s|USERSHELL=\"/bin/bash\" #;|USERSHELL=\"$USERSHELL\" #;|g" \
164+
blueprint.sh
165+
166+
# Run install script
167+
PRINT INFO "Running final install script.."
168+
chmod +x blueprint.sh
169+
mv "$FOLDER/blueprint" "$FOLDER/.blueprint"
170+
hide_progress
171+
BLUEPRINT_ENVIRONMENT="upgrade2" PROGRESS_NOW="$PROGRESS_NOW" PROGRESS_TOTAL="$PROGRESS_TOTAL" bash blueprint.sh
172+
173+
((PROGRESS_NOW++))
174+
175+
cleanup
176+
177+
# Tell user that update has finished
178+
PRINT SUCCESS "Update finished!"
179+
hide_progress
180+
exit 0
104181
}

scripts/commands/advanced/upgrade_old.sh

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,6 @@ Command() {
7979

8080
((PROGRESS_NOW++))
8181

82-
PRINT INFO "Running updater.."
83-
84-
NEW_TAG="$TAG_NAME" \
85-
OLD_TAG="$VERSION" \
86-
RAN_BY_LEGACY=false \
87-
UPDATE_FOLDER="$FOLDER/.tmp/files/update" \
88-
PROGRESS_NOW="$PROGRESS_NOW" \
89-
PROGRESS_TOTAL="$PROGRESS_TOTAL" \
90-
FOLDER="$FOLDER" \
91-
REPOSITORY="$REPOSITORY" \
92-
BLUEPRINT_ENGINE="$BLUEPRINT_ENGINE" \
93-
OWNERSHIP="$OWNERSHIP" \
94-
WEBUSER="$WEBUSER" \
95-
USERSHELL="$USERSHELL" \
96-
BLUEPRINT__DEBUG="$BLUEPRINT__DEBUG" \
97-
bash update/scripts/helpers/preupdate.sh
98-
99-
((PROGRESS_NOW++))
100-
10182
if [[ ! -d "update" ]]; then
10283
PRINT DEBUG "update directory not found.. exiting"
10384
cd "$FOLDER" || cdhalt

scripts/updater/update.sh

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
#!/bin/bash
22

3-
# $NEW_TAG: New Blueprint version that update.sh is updating to
4-
# $OLD_TAG: Old Blueprint version that update.sh is updating from
5-
# $RAN_BY_LEGACY: If this script is ran by the legacy updater
6-
# $UPDATE_FOLDER: Folder with the update files
7-
# $PROGRESS_NOW: Current loader progress
8-
# $PROGRESS_TOTAL: Total loader progress
9-
10-
# $FOLDER: Pterodactyl directory
11-
# $REPOSITORY: GitHub repository
12-
# $BLUEPRINT_ENGINE: Blueprint engine name
13-
# $OWNERSHIP: Group that owns the Pterodactyl directory permissions
14-
# $WEBUSER: User that owns the Pterodactyl directory permissions
15-
# $USERSHELL: The shell used for extension scripts and stuff
16-
# $BLUEPRINT__DEBUG: Blueprint debug directory for debug logs
17-
18-
source ../libraries/logFormat.sh || echo "could not import logformat"
19-
20-
exit 0
3+
UpdaterInstall() {
4+
# Copy release files to Pterodactyl directory
5+
PRINT INFO "Copying release files to Pterodactyl directory.."
6+
cp -r .update/repo/* .
7+
cp .eslintrc.js .
8+
cp .prettierignore .
9+
cp .prettierrc.json .
10+
cp .shellcheckrc .
11+
12+
exit 0
13+
}

0 commit comments

Comments
 (0)