-
Notifications
You must be signed in to change notification settings - Fork 8
/
upgrade.sh
executable file
·82 lines (70 loc) · 1.8 KB
/
upgrade.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# Change directory to this script's location.
cd "$(dirname "$0")"
# Set the virtual environment directory.
VIRTUALENV="$(pwd -P)/.venv"
# Install NPM packages.
COMMAND="npm install"
echo ""
echo "Installing NPM packages ($COMMAND)..."
echo ""
eval $COMMAND || exit 1
# Update NPM packages.
COMMAND="npm update"
echo ""
echo "Updating NPM packages ($COMMAND)..."
echo ""
eval $COMMAND || exit 1
# Build NPM assets.
COMMAND="npm run build"
echo ""
echo "Building NPM assets ($COMMAND)..."
echo ""
eval $COMMAND || exit 1
# Remove the existing virtual environment (if any)
if [ -d "$VIRTUALENV" ]; then
COMMAND="rm -rf ${VIRTUALENV}"
echo ""
echo "Removing old virtual environment..."
echo ""
eval $COMMAND
fi
# Create a new virtual environment
COMMAND="poetry install --no-dev"
echo ""
echo "Creating a new virtual environment at ${VIRTUALENV}..."
echo ""
eval $COMMAND || {
echo ""
echo "ERROR: Failed to create the virtual environment."
echo ""
exit 1
}
# Apply any database migrations
COMMAND="poetry run social/manage.py migrate"
echo ""
echo "Applying database migrations ($COMMAND)..."
echo ""
eval $COMMAND || exit 1
# Collect static files
COMMAND="poetry run social/manage.py collectstatic --no-input"
echo ""
echo "Collecting static files ($COMMAND)..."
echo ""
eval $COMMAND || exit 1
# Delete any stale content types
COMMAND="poetry run social/manage.py remove_stale_contenttypes --no-input"
echo ""
echo "Removing stale content types ($COMMAND)..."
echo ""
eval $COMMAND || exit 1
# Delete any expired user sessions
COMMAND="poetry run social/manage.py clearsessions"
echo ""
echo "Removing expired user sessions ($COMMAND)..."
echo ""
eval $COMMAND || exit 1
echo ""
echo "Upgrade complete! Don't forget to restart the Social services:"
echo ""
echo " > sudo systemctl restart social"