Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
aphp1_classwork80
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Egor Kremnev
aphp1_classwork80
Commits
44a170c1
Commit
44a170c1
authored
Aug 22, 2023
by
Egor Kremnev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix scripts
parent
8e2cf8cd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
27 deletions
+24
-27
apply-update.sh
scripts/apply-update.sh
+24
-27
No files found.
scripts/apply-update.sh
View file @
44a170c1
...
...
@@ -27,7 +27,8 @@ mkdir -p ${BACKUP_DIR}
BACKUP_DATE
=
$(
date
+
"%Y_%m_%d__%H_%M"
)
BACKUP_DIR_PATH
=
${
BACKUP_DIR
}
/
${
PROJECT_ROOT
}
_backup_
${
BACKUP_DATE
}
_v
${
VERSION
}
# sudo mysqldump -u [user] -p [database_name] > [filename].sql
DB_DUMP_DIR
=
${
APPLICATION_ROOT_PATH
}
/dumps/
DB_DUMP_PATH
=
${
DB_DUMP_DIR
}
backup_
${
BACKUP_DATE
}
_v
${
VERSION
}
.sql
info
()
{
echo
-e
"
\e
[33m[Info]
\e
[33m
$1
\e
[39m
$(for
i
in
{
12..21
}
;
do
echo
-en
"
\e
[33;1;
${
i
}
m.
\e
[0m"
;
done
;
echo
)
"
...
...
@@ -39,7 +40,7 @@ success() {
cd
${
APPLICATION_ROOT_PATH
}
mkdir
-p
${
STASH_DB
_DIR
}
mkdir
-p
${
DB_DUMP
_DIR
}
info
"# Creating backup"
if
[[
-f
${
DB_PATH
}
]]
;
then
...
...
@@ -55,10 +56,27 @@ fi
info
"# Extracting app package to
${
PROJECT_ROOT
}
"
mkdir
-p
${
PROJECT_ROOT
}
tar
-xzf
${
LATEST_ARTIFACT_NAME
}
-C
${
PROJECT_ROOT
}
if
[[
-f
${
STASH_DB_PATH
}
]]
;
then
info
"# Restore DB from stash"
mv
${
STASH_DB_PATH
}
${
DB_PATH
}
fi
info
"# Set environments"
env
sed
-i
''
's/^#DB_HOST=/DB_HOST=/g'
".env"
sed
-i
''
's/^\(DB_HOST=\).*/\1'
$(
[
-n
"
$DB_HOST_ENV
"
]
&&
echo
"
$DB_HOST_ENV
"
||
echo
"
$DB_HOST
"
)
'/'
".env"
sed
-i
''
's/^#DB_PORT=/DB_PORT=/g'
".env"
sed
-i
''
's/^\(DB_PORT=\).*/\1'
$(
[
-n
"
$DB_PORT_ENV
"
]
&&
echo
"
$DB_PORT_ENV
"
||
echo
"
$DB_PORT
"
)
'/'
".env"
sed
-i
''
's/^#DB_DATABASE=/DB_DATABASE=/g'
".env"
sed
-i
''
's/^\(DB_DATABASE=\).*/\1'
$(
[
-n
"
$DB_DATABASE_ENV
"
]
&&
echo
"
$DB_DATABASE_ENV
"
||
echo
"
$DB_DATABASE
"
)
'/'
".env"
sed
-i
''
's/^#DB_USERNAME=/DB_USERNAME=/g'
".env"
sed
-i
''
's/^\(DB_USERNAME=\).*/\1'
$(
[
-n
"
$DB_USERNAME_ENV
"
]
&&
echo
"
$DB_USERNAME_ENV
"
||
echo
"
$DB_USERNAME
"
)
'/'
".env"
sed
-i
''
's/^#DB_PASSWORD=/DB_PASSWORD=/g'
".env"
sed
-i
''
's/^\(DB_PASSWORD=\).*/\1'
$(
[
-n
"
$DB_PASSWORD_ENV
"
]
&&
echo
"
$DB_PASSWORD_ENV
"
||
echo
"
$DB_PASSWORD
"
)
'/'
".env"
info
"# Create database backup"
mysqldump
-u
$(
[
-n
"
$DB_DATABASE_ENV
"
]
&&
echo
"
$DB_DATABASE_ENV
"
||
echo
"
$DB_DATABASE
"
)
>
DB_DUMP_PATH
info
"# Setup permission for cache dir and storage"
chmod
-R
777
${
PROJECT_ROOT
}
/storage/
...
...
@@ -80,27 +98,6 @@ php artisan route:cache
info
"# Optimizing View Loading"
php artisan view:cache
info
"# Database folder permission"
chmod
-R
775 database
chown
-R
$(
whoami
)
database
env
sed
-i
''
's/^#DB_HOST=/DB_HOST=/g'
".env"
sed
-i
''
's/^\(DB_HOST=\).*/\1'
$(
[
-n
"
$DB_HOST_ENV
"
]
&&
echo
"
$DB_HOST_ENV
"
||
echo
"
$DB_HOST
"
)
'/'
".env"
sed
-i
''
's/^#DB_PORT=/DB_PORT=/g'
".env"
sed
-i
''
's/^\(DB_PORT=\).*/\1'
$(
[
-n
"
$DB_PORT_ENV
"
]
&&
echo
"
$DB_PORT_ENV
"
||
echo
"
$DB_PORT
"
)
'/'
".env"
sed
-i
''
's/^#DB_DATABASE=/DB_DATABASE=/g'
".env"
sed
-i
''
's/^\(DB_DATABASE=\).*/\1'
$(
[
-n
"
$DB_DATABASE_ENV
"
]
&&
echo
"
$DB_DATABASE_ENV
"
||
echo
"
$DB_DATABASE
"
)
'/'
".env"
sed
-i
''
's/^#DB_USERNAME=/DB_USERNAME=/g'
".env"
sed
-i
''
's/^\(DB_USERNAME=\).*/\1'
$(
[
-n
"
$DB_USERNAME_ENV
"
]
&&
echo
"
$DB_USERNAME_ENV
"
||
echo
"
$DB_USERNAME
"
)
'/'
".env"
sed
-i
''
's/^#DB_PASSWORD=/DB_PASSWORD=/g'
".env"
sed
-i
''
's/^\(DB_PASSWORD=\).*/\1'
$(
[
-n
"
$DB_PASSWORD_ENV
"
]
&&
echo
"
$DB_PASSWORD_ENV
"
||
echo
"
$DB_PASSWORD
"
)
'/'
".env"
php artisan migrate
--seed
# Выполним посев
info
"# Restart nginx server"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment