e67b991b444a8a73d831eb5f7dba6a5c6b9abe65
[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 ####
12
13 # something borrowed...
14 function exit_on_error() {
15   if [ $? -ne 0 ]; then
16     echo -e "\n\nan important action failed and this script will stop:\n\n$*\n\n*** Exiting script..."
17     error_sound
18     exit 1
19   fi
20 }
21
22 ####
23
24 function apt_cyg_finder()
25 {
26   if whichable apt-cyg; then
27     return 0  # success.
28 #hmmm: is that the right syntax for bash?
29   else
30     echo "
31 The apt-cyg tool does not seem to be available for cygwin.
32 Please follow the install instructions at:
33     https://github.com/transcode-open/apt-cyg
34 "
35     return 13  # not found.
36   fi
37 }
38
39 ####
40
41 # load feisty meow environment here, but first test that we *can* load it.
42
43 #hmmm: currently, this script needs the system to have already been configured?
44 #  that's the implication of calling launch_feisty...
45 #  can we find that same bootstrapping code that will reconfigure first?
46 #more about this...
47 #    hmmm: we need clean starty type approach!  must not expect feisty to already be configured for use!
48 #    e.g.?? $ bash /opt/feistymeow.org/feisty_meow/scripts/core/reconfigure_feisty_meow.sh
49 #    hmmm: above ALSO ESSENTIAL TO GET RIGHT!
50
51 PHASE_MESSAGE="Checking integrity of Feisty Meow subsystem"
52 if [ -z $FEISTY_MEOW_APEX ]; then
53   false; exit_on_error $PHASE_MESSAGE
54 fi
55
56 # simple brute force check.  can we go there?
57 pushd $FEISTY_MEOW_APEX &> /dev/null
58 exit_on_error locating feisty meow top-level folder
59 popd &> /dev/null
60
61 # now ask feisty if it's there; should work as long as our scripts are in place.
62 bash $FEISTY_MEOW_APEX/scripts/core/is_feisty_up.sh
63 exit_on_error $PHASE_MESSAGE
64
65 # standard load-up.
66 #hmmm: this will currently fail if reconfigure has never been called.
67 source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
68
69 ####
70
71 #hmmm: why two phases?
72
73 # first the crucial bits for scripts to work...
74
75 PHASE_MESSAGE="installing perl file and diff modules"
76
77 if whichable apt; then
78   # ubuntu or debian or other apt-based OSes...
79   sudo apt install libfile-which-perl libtext-diff-perl
80   exit_on_error $PHASE_MESSAGE
81 elif whichable yum; then  
82   # rpm based with yum available...
83   sudo yum install perl-File-Which perl-Text-Diff
84   exit_on_error $PHASE_MESSAGE
85 elif [ ! -z "$IS_DARWIN" ]; then
86   # macos based...
87   brew install dos2unix openssl
88   exit_on_error $PHASE_MESSAGE
89 elif [ "$OS" == "Windows_NT" ]; then
90   # windows-based with cygwin (or we'll fail out currently).
91   if apt_cyg_finder; then
92     apt-cyg install perl-File-Which perl-Text-Diff
93     exit_on_error $PHASE_MESSAGE
94   fi
95 fi
96
97 ####
98
99 # then the builder packages...
100
101 PHASE_MESSAGE="installing code builder packages"
102
103 if whichable apt; then
104   # ubuntu or debian or other apt-based OSes...
105   sudo apt install mawk build-essential librtmp-dev libcurl4-gnutls-dev libssl-dev
106   exit_on_error $PHASE_MESSAGE
107 elif whichable yum; then  
108   # rpm based with yum available...
109   sudo yum install mawk gcc gcc-c++ openssl-devel.x86_64 curl-devel
110   exit_on_error $PHASE_MESSAGE
111 elif [ ! -z "$IS_DARWIN" ]; then
112   # macos based...
113 #hmmm: still working on these...
114   brew install mawk gpg meld openjdk 
115   exit_on_error $PHASE_MESSAGE
116 elif [ "$OS" == "Windows_NT" ]; then
117   # windows-based with cygwin (or we'll fail out).
118
119   if apt_cyg_finder; then
120 echo need to fix apt cyg install list somewhat.
121 #hmmm: list is in our docs as a separate file for cygwin.
122 #      plug those packages into here please.
123     apt-cyg install mawk openssl-devel libz-devel curl-devel 
124     exit_on_error $PHASE_MESSAGE
125   fi
126 fi
127
128 ####
129
130 # install other external packages and whatnot.
131
132 #hmmm: anything else to get installed?
133   #hmmm: java?
134   #hmmm: python?
135   #hmmm: perl itself!?
136
137
138 ####
139
140 # get ready to finish up.
141
142 #...finishing steps...  if any.
143
144 # all done now.
145 exit 0
146
147 ####
148
149
150 #############################
151 #scav line
152 #############################
153
154 The "kona" collection depends on Java version 8 or better.
155 | Ubuntu:
156 | Set up the java PPA archive as described here:
157 | https://launchpad.net/~webupd8team/+archive/ubuntu/java
158
159 #not needed at the moment.
160 #echo "bailing because script is immature.  farts!"
161 #exit 1
162