Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 154 lines (146 sloc) 4.938 kb
40bc42cd » eldios
2011-04-25 + added README.md (5%)
1 #!/bin/bash
1f8407b3 » gradus
2012-03-17 add ability to install missing modules in dependencies_verify.sh
2 # simple script to verify if your system already has the needed binary for express
40bc42cd » eldios
2011-04-25 + added README.md (5%)
3
60dea91b » chrismatthieu
2011-12-28 updated mac section
4 echo " _ _"
5 echo " | | | |"
6 echo " _ __ ___ __| | ___ ___| |_ ___ _ __"
7 echo "| '_ \ / _ \ / _' |/ _ \/ __| __/ _ \ '__|"
8 echo "| | | | (_) | (_| | __/\__ \ || __/ |"
9 echo "|_| |_|\___/ \__,_|\___||___/\__\___|_|"
10 echo ""
11
1f96e89c » eldios
2011-04-26 + added env_creation script (50%)
12 # define your system dependencies here
13 declare -a sys_dependencies
75ea944a » gradus
2012-03-18 add git as sys dependency check in dependencies_verify.sh
14 sys_dependencies=("node" "npm" "curl" "git")
15
1f96e89c » eldios
2011-04-26 + added env_creation script (50%)
16 # define your npm dependencies here
17 declare -a npm_modules_dependencies
10ae3af9 » System Administrator
2011-12-28 initial commit from eldios
18 npm_modules_dependencies=("pool" "express" "request" "npm-wrapper" "daemon" "cradle" "connect" "coffee-script" "colors" "nodemailer" "bouncy" "nodeinfo")
23f77f3f » eldios
2011-04-26 enhancements on dep verify script
19
40bc42cd » eldios
2011-04-25 + added README.md (5%)
20 # color used for printing
1f96e89c » eldios
2011-04-26 + added env_creation script (50%)
21 use_color=true
40bc42cd » eldios
2011-04-25 + added README.md (5%)
22 if ($use_color) ;
23 then
1f96e89c » eldios
2011-04-26 + added env_creation script (50%)
24 BLDYEL=$(tput bold ; tput setaf 3)
40bc42cd » eldios
2011-04-25 + added README.md (5%)
25 BLDVIO=$(tput bold ; tput setaf 5)
26 BLDCYA=$(tput bold ; tput setaf 6)
27 BLDRED=$(tput bold ; tput setaf 1)
28 BLDGRN=$(tput bold ; tput setaf 2)
29 NOCOLR=$(tput sgr0)
30 fi
31
32 # checking system dependencies
1f96e89c » eldios
2011-04-26 + added env_creation script (50%)
33 declare -a sys_deps_not_ok
34 sys_deps_not_ok=()
40bc42cd » eldios
2011-04-25 + added README.md (5%)
35 for sys_dep in ${sys_dependencies[@]}
36 do
37 type -P $sys_dep &>/dev/null \
38 && {
39 DEP_OK="I need $sys_dep and it is correctly installed." ;
40 OK_MSG="OK - :)";
41 TRM_COL=$(tput cols) ; DEP_COL_OK=${#DEP_OK} ; OK_MSG_COL=${#OK_MSG} ;
42 COL_OK=$(( $TRM_COL - $DEP_COL_OK - $OK_MSG_COL )) ;
43 sys_dep="${BLDCYA}${sys_dep}${NOCOLR}"
44 DEP_OK="I need $sys_dep and it is correctly installed." ;
45 printf '%s%*s%s' "$DEP_OK" $COL_OK "[${BLDGRN}${OK_MSG}${NOCOLR}]" >&2;
46 echo ;
47 } \
48 || {
1f8407b3 » gradus
2012-03-17 add ability to install missing modules in dependencies_verify.sh
49 DEP_KO="I need $sys_dep but it is missing." ;
40bc42cd » eldios
2011-04-25 + added README.md (5%)
50 KO_MSG="KO - :(";
51 TRM_COL=$(tput cols) ; DEP_COL_KO=${#DEP_KO} ; KO_MSG_COL=${#KO_MSG} ;
52 COL_KO=$(( $TRM_COL - $DEP_COL_KO - $KO_MSG_COL )) ;
53 sys_dep="${BLDCYA}${sys_dep}${NOCOLR}"
1f8407b3 » gradus
2012-03-17 add ability to install missing modules in dependencies_verify.sh
54 DEP_KO="I need $sys_dep but it is missing." ;
40bc42cd » eldios
2011-04-25 + added README.md (5%)
55 printf '%s%*s%s' "$DEP_KO" $COL_KO "[${BLDRED}${KO_MSG}${NOCOLR}]" >&2;
56 echo ;
23f77f3f » eldios
2011-04-26 enhancements on dep verify script
57 new_len=$(( ${#sys_deps_not_ok[@]} + 1 ))
1f96e89c » eldios
2011-04-26 + added env_creation script (50%)
58 sys_deps_not_ok[$new_len]=$sys_dep
40bc42cd » eldios
2011-04-25 + added README.md (5%)
59 }
60 done
61 # checking npm dependencies
1f96e89c » eldios
2011-04-26 + added env_creation script (50%)
62 declare -a npm_deps_not_ok
1f8407b3 » gradus
2012-03-17 add ability to install missing modules in dependencies_verify.sh
63 declare -a npm_deps_to_install
64 npm_deps_to_install=()
1f96e89c » eldios
2011-04-26 + added env_creation script (50%)
65 npm_deps_not_ok=()
40bc42cd » eldios
2011-04-25 + added README.md (5%)
66 for npm_mod in ${npm_modules_dependencies[@]}
67 do
86afbc6a » eldios
2011-04-28 package.json almost finished
68 npm_version=`npm --version 2>&1`
69 if [ $( echo $npm_version | grep -E '^0\.[1-3]\..*$' ) ] ; then
70 installed=$(npm ls installed 2>&1 | grep -E "^$npm_mod\\@.*installed.*$" | wc -l)
71 elif [ $( echo $npm_version | grep -E '1\.[0-1]\..*' ) ] ; then
72 installed=$(npm -dg ls 2>&1 | grep -E '[โ”œโ”‚โ””]' | grep " $npm_mod\\@" | wc -l)
73 else
74 installed="0"
75 fi
76 if [ "${installed}" -gt "0" ] ;
77 then
40bc42cd » eldios
2011-04-25 + added README.md (5%)
78 DEP_OK="I need $npm_mod and it is correctly installed." ;
79 OK_MSG="OK - :)";
80 TRM_COL=$(tput cols) ; DEP_COL_OK=${#DEP_OK} ; OK_MSG_COL=${#OK_MSG} ;
81 COL_OK=$(( $TRM_COL - $DEP_COL_OK - $OK_MSG_COL )) ;
82 npm_mod="${BLDVIO}${npm_mod}${NOCOLR}"
83 DEP_OK="I need $npm_mod and it is correctly installed." ;
84 printf '%s%*s%s' "$DEP_OK" $COL_OK "[${BLDGRN}${OK_MSG}${NOCOLR}]" >&2;
85 echo ;
86afbc6a » eldios
2011-04-28 package.json almost finished
86 else
1f8407b3 » gradus
2012-03-17 add ability to install missing modules in dependencies_verify.sh
87 DEP_KO="I need $npm_mod but it is missing." ;
40bc42cd » eldios
2011-04-25 + added README.md (5%)
88 KO_MSG="KO - :(";
89 TRM_COL=$(tput cols) ; DEP_COL_KO=${#DEP_KO} ; KO_MSG_COL=${#KO_MSG} ;
1f8407b3 » gradus
2012-03-17 add ability to install missing modules in dependencies_verify.sh
90 COL_KO=$(( $TRM_COL - $DEP_COL_KO - $KO_MSG_COL )) ;
91 npm_mod_to_install="${npm_mod}"
40bc42cd » eldios
2011-04-25 + added README.md (5%)
92 npm_mod="${BLDVIO}${npm_mod}${NOCOLR}"
1f8407b3 » gradus
2012-03-17 add ability to install missing modules in dependencies_verify.sh
93 DEP_KO="I need $npm_mod but it is missing." ;
40bc42cd » eldios
2011-04-25 + added README.md (5%)
94 printf '%s%*s%s' "$DEP_KO" $COL_KO "[${BLDRED}${KO_MSG}${NOCOLR}]" >&2;
95 echo ;
23f77f3f » eldios
2011-04-26 enhancements on dep verify script
96 new_len=$(( ${#npm_deps_not_ok[@]} + 1 ))
1f96e89c » eldios
2011-04-26 + added env_creation script (50%)
97 npm_deps_not_ok[$new_len]=$npm_mod
1f8407b3 » gradus
2012-03-17 add ability to install missing modules in dependencies_verify.sh
98 new_install=$(( ${#npm_deps_to_install[@]} + 1 ))
99 npm_deps_to_install[$new_install]=$npm_mod_to_install
100
86afbc6a » eldios
2011-04-28 package.json almost finished
101 fi
40bc42cd » eldios
2011-04-25 + added README.md (5%)
102 done
103 # printing missing dependencies
1f96e89c » eldios
2011-04-26 + added env_creation script (50%)
104 if [ "${#sys_deps_not_ok[@]}" -gt "0" ] ;
105 then
106 echo -n "System Components ${BLDYEL}not found${NOCOLR}: "
107 for i in "${sys_deps_not_ok[@]}"
108 do
109 echo -n "$i "
110 done
111 echo
112 fi
113 if [ "${#npm_deps_not_ok[@]}" -gt "0" ] ;
114 then
1f8407b3 » gradus
2012-03-17 add ability to install missing modules in dependencies_verify.sh
115 echo -n "NPM modules ${BLDYEL}not found${NOCOLR}: "
1f96e89c » eldios
2011-04-26 + added env_creation script (50%)
116 for i in "${npm_deps_not_ok[@]}"
117 do
118 echo -n "$i "
119 done
1f8407b3 » gradus
2012-03-17 add ability to install missing modules in dependencies_verify.sh
120 echo ;
121 echo ;
122 echo -n "I can install these missing NPM modules for you."
123 echo ;
124 echo -n "Typing ${BLDYEL}yes${NOCOLR} will run ${BLDYEL}npm install${NOCOLR} ${BLDVIO}[missing module]${NOCOLR} ${BLDYEL}-g${NOCOLR}"
125 echo ;
126 echo -n "Would you like to install these dependencies globally? [type ${BLDYEL}yes${NOCOLR} to proceed]: "
127 read install_npm_modules
128 if [ "$install_npm_modules" == 'yes' ] ;
129 then
130 for i in "${npm_deps_to_install[@]}"
131 do
132 echo -n "installing npm module ${BLDVIO}$i${NOCOLR}"
133 echo ;
134 sh -c "npm install $i -g"
135 echo ;
136 done
137 echo ;
138 else
139 echo ;
140 echo -n "The following NPM modules will need to be installed manually before nodester can be installed" ;
141 echo ;
142 for i in "${npm_deps_not_ok[@]}"
143 do
144 echo -n "$i "
145 done
146 echo
147
148 fi
1f96e89c » eldios
2011-04-26 + added env_creation script (50%)
149 fi
1f8407b3 » gradus
2012-03-17 add ability to install missing modules in dependencies_verify.sh
150
86afbc6a » eldios
2011-04-28 package.json almost finished
151 if [ "${#sys_deps_not_ok[@]}" -gt "0" ] || [ "${#npm_deps_not_ok[@]}" -gt "0" ] ;
152 then
153 exit 1
154 fi
Something went wrong with that request. Please try again.