-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·72 lines (53 loc) · 1.45 KB
/
Copy pathupdate.sh
File metadata and controls
executable file
·72 lines (53 loc) · 1.45 KB
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
#!/bin/bash
# exit with 1: restart
# 0: success, stop the service
# Set source and destination directories from arguments
sourceDir="/mnt/update/latestVersion"
destDir="/usr/local/bin"
# Display source and destination directories
echo "Source directory: $sourceDir"
echo "Destination directory: $destDir"
# https://man7.org/linux/man-pages/man1/mountpoint.1.html
if mountpoint -q /mnt/update; then
echo "/mnt/update already mounted"
else
# Create the directory using 'mkdir -p' if it doesn't exist.
mkdir -p /mnt/update
mount /dev/mmcblk1p3 /mnt/update
# Check if the mount was successful
# check the exit status of the previous command executed in the script
if [ $? -eq 0 ]; then
echo "/mnt/update mounted successfully"
else
echo "Failed to mount /mnt/update"
exit 0
fi
fi
cd "$sourceDir"
if [ -f "update.zip" ]; then
echo "File 'update.zip' exists."
else
echo "File 'update.zip' does not exist."
exit 0
fi
rm -rf "content"
unzip "update.zip" -d "content"
cd "content"
gunzip *
echo "stopping watchdog process"
pkill watchdog_stherm
echo "watchdog process stopped"
echo "stopping service"
systemctl stop appStherm.service
echo "service stopped"
sleep 10
echo "copying ... "
# Perform file copy operation from source to destination
cp -r * "$destDir"/
echo "cleaning up "
rm -rf $sourceDir/*
echo "starting service"
sleep 2
systemctl start appStherm.service
# Exit with success code
exit 0