-
Notifications
You must be signed in to change notification settings - Fork 18
/
build.sh
executable file
·66 lines (55 loc) · 1.75 KB
/
build.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
#!/bin/bash
# Check if an external device exists
if [ -e /run/media/$USER/* ]; then
# Build the .xo file
echo 'Found external device.'
echo 'Building xo file...'
./setup.py dist_xo
file=dist/*.xo
$(echo $file | cut -f1 -d-)
# Check if the file already exists
if [ -e /run/media/$USER/*/$file ]; then
echo 'Removing version on device...'
rm /run/media/$USER/*/$file
fi
# Move the new file onto the external device
echo 'Moving xo file to device...'
mv $file /run/media/$USER/*/
echo 'Cleaning up...'
rm -r dist/
# Notify the user a device was not found
else
echo 'No external device found.'
echo 'Building xo file...'
./setup.py dist_xo
file=dist/*.xo
activity=$(echo $(echo $file | cut -f1 -d-) | cut -f2 -d/)
# Check if there is a current version of the xo file in your directory
if [ -e ./$activity-*.xo ]; then
# Prompt the user if they would like to replace the file or not
echo -n 'Would you like to replace the current xo file? [y/n]: '
read answer
# If the user wants to replace the file, replace it
if [ "$answer" == "y" ]; then
echo 'Removing previous version...'
rm ./$activity-*.xo
mv dist/* ./
# If the user does not want to replace the file,
# save the old one and create the new file
elif [ "$answer" == "n" ]; then
old=$activity-*.xo
mv ./$old ./$activity.old.xo
mv ./$file ./$activity.new.xo
else
echo 'Invalid input.'
echo 'Aborting.'
rm -r dist/
exit 1
fi
else
mv dist/* ./
fi
echo 'Cleaning up...'
rm -r dist/
fi
echo 'Finished!'