Create engine kubernetes stack
[infra/stack/kubernetes.git] / playbooks / roles / package / files / decompress.sh
1 #!/bin/bash
2 # ============LICENSE_START=======================================================
3 #  Copyright (C) 2019 The Nordix Foundation. All rights reserved.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
19
20 set -o errexit
21 set -o nounset
22 set -o pipefail
23
24 cat <<EOF
25 #---------------------------------------------------#
26 #             Self Extracting Installer             #
27 #---------------------------------------------------#
28 User            : $USER
29 Hostname        : $HOSTNAME
30 Host OS         : $(source /etc/os-release &> /dev/null || source /usr/lib/os-release &> /dev/null; echo "${PRETTY_NAME}")
31 IP              : $(hostname -I | cut -d' ' -f1)
32 #---------------------------------------------------#
33 Info  : Please wait while extracting dependencies.
34         This might take a while.
35 #---------------------------------------------------#
36 EOF
37
38 ENGINE_WORKSPACE=/opt/engine
39 DESTINATION_FOLDER="$ENGINE_WORKSPACE/offline"
40 export ENGINE_WORKSPACE DESTINATION_FOLDER
41
42 # NOTE (fdegir): we need to clean things up in order to prevent side effects from leftovers
43 sudo rm -rf "$ENGINE_WORKSPACE"
44 sudo mkdir -p "$DESTINATION_FOLDER"
45 sudo chown -R "$USER":"$USER" "$ENGINE_WORKSPACE"
46
47 ARCHIVE=$(awk '/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0; }' "$0")
48
49 tail -n+"$ARCHIVE" "$0" | tar -xz -C "$DESTINATION_FOLDER"
50
51 cd "$DESTINATION_FOLDER"
52 ./install.sh
53
54 exit 0
55 __ARCHIVE_BELOW__