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