-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepare
More file actions
executable file
·129 lines (105 loc) · 3.39 KB
/
prepare
File metadata and controls
executable file
·129 lines (105 loc) · 3.39 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/sh
# docker version to be installed
DOCKER_VERSION="18.06.2"
DOCKER_COMPOSE_VERSION="1.23.2"
ARCH="$(uname -m)"
LOCATION="/srv/repo"
if [ "$#" = 0 ] || ([ "$#" = 1 ] && [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$1" = "help" ]); then
echo "
Usage: ./prepare -r [OPTIONS]
A script that prepares a bundle which can be used to install
docker and docker-compose with respect to user permissions
Commands:
-r : Starts preparing the bundle for your remote device
help : Help instructions
Options:
-p : Location of where to put installation bundle
-a : Set target architecture. Default: x86_64 (type 'uname -m' on remote device)
possible architectures: aarch64 armel armhf ppc64le s390x x86_64
"
exit
fi
while getopts ":p:a:" option
do
case "${option}"
in
p) LOCATION_USER=${OPTARG};;
a) ARCH_USER=${OPTARG};;
:) NOARG=;;
esac
done
# this is our run procedure
if [ "$#" -ge 1 ] && [ "$1" = "-r" ]; then
if [ ! -z "$ARCH_USER" ]; then
ARCH=$ARCH_USER
fi
# check if docker sources available
if [ ! -f 'src/docker-'"$ARCH"'.tgz' ]; then
# doker download can not be found. then download it
sudo apt install -y curl
url='https://download.docker.com/linux/static/stable/'"$ARCH"'/docker-'"$DOCKER_VERSION"'-ce.tgz'
echo "docker is being downloaded"
if [ ! -d src ]; then
mkdir src
fi
wget -O 'src/docker-'"$ARCH"'.tgz' $url
else
echo 'src/docker-'"$ARCH"'.tgz has been found!'
fi
# check if docker-compose file available
if [ ! -f 'src/docker-compose-'"$ARCH" ]; then
# doker download can not be found. then download it
sudo apt install -y curl
url='https://github.com/docker/compose/releases/download/'"$DOCKER_COMPOSE_VERSION"'/docker-compose-Linux-'"$ARCH"
echo "docker-compose is being downloaded"
wget -O 'src/docker-compose-'"$ARCH" $url
else
echo 'src/docker-compose-'"$ARCH"' has been found!'
fi
# we assume that now we have src/docker.tgz and docker-compose files
# now prepare the bundle
sudo apt install -y tar
if [ -d bundle ]; then
echo "bundle directory found!"
rm -rf bundle
echo "now removed..."
fi
mkdir bundle
tar xzvf 'src/docker-'"$ARCH"'.tgz' --directory "$PWD/bundle"
cp 'src/docker-compose-'"$ARCH" bundle/docker/docker-compose
cp docker.service bundle/docker.service
cp manage-docker bundle/manage-docker
cp install bundle/install
tar -zcvf bundle.tar.gz bundle
rm -rf bundle
sudo mkdir $LOCATION
sudo mv bundle.tar.gz $LOCATION
if [ ! -z "$LOCATION_USER" ]; then
LOCATION=$LOCATION_USER
mv bundle.tar.gz $LOCATION
fi
clear
echo "
docker engine bundle has been prepared successfully for $ARCH!
your bundle is in: $LOCATION
now you should
- send bundle.tar.gz to your IoT device with your protocol
- run following commands in device:
$> tar xzvf bundle.tar.gz
$> sudo ./bundle/install
"
else
echo "
Usage: ./prepare -r [OPTIONS]
A script that prepares a bundle which can be used to install
docker and docker-compose with respect to user permissions
Commands:
-r : Starts preparing the bundle for your remote device
help : Help instructions
Options:
-p : Location of where to put installation bundle
-a : Set target architecture. Default: x86_64 (type 'uname -m' on remote device)
"
exit
fi
#EOF