c068fa5a5e79de56e2d29ebb88224774d416294b
[feisty_meow.git] / scripts / core / prep_feisty_host.sh
1 #!/bin/bash
2
3 # this is the feisty meow host preparation script.  it installs all the packages required to run and build feisty meow scripts and applications.
4 # this script may still be a bit incomplete; we definitely use a lot of unix and linux tools in different scripts.
5
6 # preconditions and dependencies--this script itself depends on:
7 #   feisty meow
8 #   bash
9 #   anything else?
10
11 #weird approach here man.
12 #  why are we assuming any part of feisty meow is set up yet?
13 #  the dependencies that the codebase has are why we're installing things below.
14 #  so:
15 #    + intuit the feisty meow location based on relative dir placement.
16 #    + reduce checks to barest presence ones.
17 #    + drop any requirements on feisty functions that might require the
18 #      very code we're installing.
19
20
21 ####
22
23 # helper scripts...
24
25 function exit_on_error() {
26   if [ $? -ne 0 ]; then
27     echo -e "\n\nan important action failed and this script will stop:\n\n$*\n\n*** Exiting script..."
28 #    error_sound
29     exit 1
30   fi
31 }
32
33 function whichable()
34 {
35   to_find="$1";
36   shift;
37   local WHICHER="$(/usr/bin/which which 2>/dev/null)";
38   if [ $? -ne 0 ]; then
39       echo;
40       return 2;
41   fi;
42   local sporkenz;
43   sporkenz=$($WHICHER "$to_find" 2>/dev/null);
44   local err=$?;
45   echo $sporkenz;
46   return $err
47 }
48
49 ####
50
51 function apt_cyg_finder()
52 {
53   if whichable apt-cyg; then
54     return 0  # success.
55 #hmmm: is that the right syntax for bash?
56   else
57     echo "
58 The apt-cyg tool does not seem to be available for cygwin.
59 Please follow the install instructions at:
60     https://github.com/transcode-open/apt-cyg
61 "
62     return 13  # not found.
63   fi
64 }
65
66 ####
67
68 # load feisty meow environment here, but first test that we *can* load it.
69
70 #hmmm: currently, this script needs the system to have already been configured?
71 #  that's the implication of calling launch_feisty...
72 #  can we find that same bootstrapping code that will reconfigure first?
73 #more about this...
74 #    hmmm: we need clean starty type approach!  must not expect feisty to already be configured for use!
75 #    e.g.?? $ bash /opt/feistymeow.org/feisty_meow/scripts/core/reconfigure_feisty_meow.sh
76 #    hmmm: above ALSO ESSENTIAL TO GET RIGHT!
77
78 BASE_PHASE_MESSAGE="Feisty Meow subsystems integrity check: "
79
80 # is our main variable set?
81 PHASE_MESSAGE="$BASE_PHASE_MESSAGE presence of FEISTY_MEOW_APEX variable"
82 if [ -z "$FEISTY_MEOW_APEX" ]; then
83   false; exit_on_error $PHASE_MESSAGE
84 fi
85
86 # simple brute force check.  can we go there?
87 PHASE_MESSAGE="$BASE_PHASE_MESSAGE check on directory $FEISTY_MEOW_APEX"
88 pushd $FEISTY_MEOW_APEX &> /dev/null
89 exit_on_error $PHASE_MESSAGE
90 popd &> /dev/null
91
92 # now ask feisty if it's there; should work as long as our scripts are in place.
93 #PHASE_MESSAGE="$BASE_PHASE_MESSAGE inquiry is_feisty_up"
94 #bash $FEISTY_MEOW_APEX/scripts/core/is_feisty_up.sh
95 #exit_on_error $PHASE_MESSAGE
96
97 # standard load-up.
98 #hmmm: this will currently fail if reconfigure has never been called.
99 #NO NO NO. source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
100 # we are preparing to get feisty running; how can we use feisty during
101 # that process?  so bad.
102
103 ####
104
105 #hmmm: why two phases?
106
107 # first the crucial bits for scripts to work...
108
109 PHASE_MESSAGE="installing perl file and diff modules"
110
111 if whichable apt; then
112   # ubuntu or debian or other apt-based OSes...
113   sudo apt install libfile-which-perl libtext-diff-perl
114   exit_on_error $PHASE_MESSAGE
115 elif whichable yum; then  
116   # rpm based with yum available...
117   sudo yum install perl-Env perl-File-Which perl-Text-Diff
118   exit_on_error $PHASE_MESSAGE
119 elif [ ! -z "$IS_DARWIN" ]; then
120   # macos based...
121   brew install dos2unix openssl
122   exit_on_error $PHASE_MESSAGE
123 elif [ "$OS" == "Windows_NT" ]; then
124   # windows-based with cygwin (or we'll fail out currently).
125   if apt_cyg_finder; then
126     apt-cyg install perl-File-Which perl-Text-Diff
127     exit_on_error $PHASE_MESSAGE
128   fi
129 fi
130
131 ####
132
133 # then the builder packages...
134
135 PHASE_MESSAGE="installing code builder packages"
136
137 if whichable apt; then
138   # ubuntu or debian or other apt-based OSes...
139   sudo apt install mawk build-essential librtmp-dev libcurl4-gnutls-dev libssl-dev
140   exit_on_error $PHASE_MESSAGE
141 elif whichable yum; then  
142   # rpm based with yum available...
143   sudo yum install curl-devel gcc gcc-c++ make mawk openssl-devel.x86_64 zlib-devel
144   exit_on_error $PHASE_MESSAGE
145 elif [ ! -z "$IS_DARWIN" ]; then
146   # macos based...
147 #hmmm: still working on these...
148   brew install mawk gpg meld openjdk 
149   exit_on_error $PHASE_MESSAGE
150 elif [ "$OS" == "Windows_NT" ]; then
151   # windows-based with cygwin (or we'll fail out).
152
153   if apt_cyg_finder; then
154 echo need to fix apt cyg install list somewhat.
155 #hmmm: list is in our docs as a separate file for cygwin.
156 #      plug those packages into here please.
157     apt-cyg install gawk libcurl-devel meld mingw64-i686-openssl openssl openssl-devel libssl-devel zlib-devel
158     exit_on_error $PHASE_MESSAGE
159
160 #extended set.  just add them?
161 # xorg-server xorg-docs xlaunch 
162
163   fi
164 fi
165
166 ####
167
168 # install other external packages and whatnot.
169
170 #hmmm: anything else to get installed?
171   #hmmm: java?
172   #hmmm: python?
173   #hmmm: perl itself!?
174
175
176 ####
177
178 # get ready to finish up.
179
180 #...finishing steps...  if any.
181
182 # all done now.
183 exit 0
184
185 ####
186
187
188 #############################
189 #scav line
190 #############################
191
192 The "kona" collection depends on Java version 8 or better.
193 | Ubuntu:
194 | Set up the java PPA archive as described here:
195 | https://launchpad.net/~webupd8team/+archive/ubuntu/java
196
197 #not needed at the moment.
198 #echo "bailing because script is immature.  farts!"
199 #exit 1
200