UNPKG

2.98 kBapplication/x-shView Raw
1#!/usr/bin/env bash
2
3set -e;
4
5export SUMAN_DEBUG_LOG_PATH="$HOME/.suman/logs/suman-postinstall-debug.log"
6SUMAN_POSTINSTALL_IS_DAEMON=${SUMAN_POSTINSTALL_IS_DAEMON:-no}
7
8mkdir -p "$HOME/.suman" && echo "created suman dir" || { echo " could not create suman dir"; exit 1; }
9mkdir -p "$HOME/.suman/logs" && echo "create logs dir" || { echo " could not create logs dir"; exit 1; }
10mkdir -p "$HOME/.suman/global" && echo "created global dir" || { echo " could not create global dir"; exit 1; }
11mkdir -p "$HOME/.suman/database" && echo "created database dir" || { echo " could not create database dir"; exit 1; }
12
13if [ -e ${SUMAN_DEBUG_LOG_PATH} ]; then
14 echo "new install run" > ${SUMAN_DEBUG_LOG_PATH} && echo "created debug log file" \
15 || { echo " could not create log file"; exit 1; }
16else
17 echo "new install run" >> ${SUMAN_DEBUG_LOG_PATH} && echo "created debug log file" \
18 || { echo " could not create log file"; exit 1; }
19fi
20
21SUMAN_START_TIME=$(node -e 'console.log(Date.now())')
22SUMAN_DEBUG="$(echo -e "${SUMAN_DEBUG}" | tr -d '[:space:]')"
23
24SUMAN_IN_CONTAINER="no";
25
26if [[ "lxc" == "${container}" ]]; then
27 SUMAN_IN_CONTAINER="yes";
28 echo " => Suman says => We are in a (Docker) container because of the
29 container env var! " | tee -a ${SUMAN_DEBUG_LOG_PATH}
30fi
31
32if [[ -f ~/.dockerenv ]]; then
33 SUMAN_IN_CONTAINER="yes";
34 echo " => Suman says => We are in a (Docker)
35 container because of the presence of .dockerenv file! " | tee -a ${SUMAN_DEBUG_LOG_PATH}
36fi
37
38./scripts/create-suman-dir.js
39
40DOT_SUMAN_DIR=$(cd ~/.suman && pwd)
41SUMAN_INSTALL_NODE_MODULES="yes";
42
43if [[ ! -d "$DOT_SUMAN_DIR" ]]; then
44 echo " => Warning => Suman failed to create ~/.suman directory." | tee -a ${SUMAN_DEBUG_LOG_PATH}
45 SUMAN_INSTALL_NODE_MODULES="no";
46fi
47
48if [[ "${SUMAN_INSTALL_NODE_MODULES}" == "yes" ]]; then
49
50
51(
52
53 cd "$HOME/.suman/global";
54
55 npm init -f >> ${SUMAN_DEBUG_LOG_PATH} 2>&1
56
57 if [[ ! -d "node_modules/handlebars" ]]; then
58 npm install -S handlebars
59 fi
60
61 if [[ ! -d "node_modules/typescript" ]]; then
62 npm install -S typescript
63 fi
64
65 if [[ ! -d "node_modules/ts-node" ]]; then
66 npm install -S ts-node
67 fi
68
69 if [[ ! -d "node_modules/istanbul" ]]; then
70 npm install -S istanbul
71 fi
72
73 if [[ ! -d "node_modules/nyc" ]]; then
74 npm install -S nyc
75 fi
76
77 if [[ ! -d "node_modules/suman-inquirer" ]]; then
78 npm install -S suman-inquirer
79 fi
80
81 if [[ ! -d "node_modules/suman-inquirer-directory" ]]; then
82 npm install -S suman-inquirer-directory
83 fi
84
85 if [[ ! -d "node_modules/babel-core" ]]; then
86 npm install -S babel-core
87 fi
88
89 if [[ ! -d "node_modules/babel-runtime" ]]; then
90 npm install -S babel-runtime
91 fi
92
93)
94
95fi
96
97SUMAN_END_TIME=$(node -e 'console.log(Date.now())')
98SUMAN_TOTAL_TIME=$(expr ${SUMAN_END_TIME} - ${SUMAN_START_TIME})
99echo " => Suman => all done with postinstall routine after ${SUMAN_TOTAL_TIME}ms. " | tee -a ${SUMAN_DEBUG_LOG_PATH}
100
101# explicit for your pleasure
102exit 0;