-
Notifications
You must be signed in to change notification settings - Fork 3
/
upgrade.sh
executable file
·73 lines (62 loc) · 1.64 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
#!/bin/sh
#
# This script copies the data from an older version of a bot to a newer installation, and copies to older one to a folder ending with '.old_Version'
#
# Usage: `./upgrade.sh OLD_BOT_LOCATION NEW_BOT_LOCATION`
#
#
# NOTE: when doing an upgrade you have to use the same bot client for the integration since only the bot
# that encrypted the config values and user database can decrypt them as well
#
if [ "$#" -ne 2 ]
then
echo "Usage: $0 <old location> <new location>"
exit 1
fi
if ! [ -d "$1" ] || ! [ -d "$2" ]
then
echo "Both locations should be directories!"
exit 1
fi
#
# Save the input values:
# Example:
# old location: '/opt/WickrIODebug/clients/bcast_bot/integration/proxy_bot'
# new location: '/opt/WickrIODebug/clients/bcast_bot/integration/proxy_bot.new'
#
export OLD_BOT_LOCATION=$1
export NEW_BOT_LOCATION=$2
cd $OLD_BOT_LOCATION
#
# Copy the json data files to the new software location
#
set +e
# need to convert the WHITELISTED_USERS to ADMINISTRATORS
sed -e "s/WHITELISTED_USERS/ADMINISTRATORS/g" <processes.json > $NEW_BOT_LOCATION/processes.json
cp -f users.txt credentials.json setupData.json $NEW_BOT_LOCATION
set -e
#
# Copy the attachment files to the new software location
#
set +e
cp -rf attachments files $NEW_BOT_LOCATION
set -e
#
# Move the OLD installation to a saved directory
# Remove a previous one if necessary
#
cd ..
echo $PWD
ls
rm -rf proxy_bot.old_Version
mv $OLD_BOT_LOCATION proxy_bot.old_Version
#
# Move the NEW installation to the bot's integration directory
#
cd $NEW_BOT_LOCATION/..
mv $NEW_BOT_LOCATION $OLD_BOT_LOCATION
#
# Change the script value in processes.json
#
cd $OLD_BOT_LOCATION
node upgrade.js