#!/bin/sh ## ## SCRIPT: 02_extractFromSelf_code_forCat2tarfile_ofAppMenusDirs.sh ## ## PURPOSE: Extracts all the bytes after the bottom of this script. ## Puts the bytes into a temp file. Then ungzips and untars that temp file, ## into a specified install directory. Also puts a couple of shell include ## files in a $HOME/.freedomenv subdirectory. ## ## To do the self-extract, this script ## uses 'tail -n +LINENUM', where LINENUM is the ## number of lines to the bottom of this script, plus 1. ## ## ******* NOTE!!! If you edit this script, reset that number, if need be. ## ******* !!!!!!! AND ALWAYS reset the release date in the INSTALLDIR var. ## ## This script is meant to be concatenated with a ## gzipped tar file --- making a new script file. ## ## (Do chmod 755 on that new file, to do the install with that combined ## script-and-gzipped-tar file.) ## ## Example (continued onto a 2nd line): ## ## 1) cat 02_extractFromSelf_code_forCat2tarfile_ofAppMenusDirs.sh feAppMenus_yyyymmmdd.tar.gz \ ## > extractFromSelf_feAppMenusFiles_yyyymmmdd.sh ## ##-------- ## ## For the user to do an install, download extractFromSelf_feAppMenusFiles_yyyymmmdd.sh, ## and ## 2) chmod 755 extractFromSelf_feAppMenusFiles_yyyymmmdd.sh ## ## For the user to do an install, in any dir, run ## 3) ./extractFromSelf_feAppMenusFiles_yyyymmmdd.sh ## ## That new, concatenated script file, when run by the user-installer, as ## indicated by steps 2 and 3 above, is then supposed to extract the bytes ## of the tar-gzipped file and put it into a temp file. ## Then the script untars the temp file into the install directory, in the ## 'apps' directory of the user's home directory. ## ## Started: 2010sep09 Based on the script for the 'xpg' FE subsystem. ## Changed: 2010sep17 Updated the script for a 2010sep17 release. ## Turn ON display of executed-statements. set -x ############################################## ## Make the $HOME/apps dir for the user, ## if none exists, at his/her machine. ############################################## DIR_HOMEAPPS="$HOME/apps" if test ! -d "$DIR_HOMEAPPS" then mkdir "$DIR_HOMEAPPS" chmod 755 "$DIR_HOMEAPPS" fi ############################################## ## If the dir $HOME/apps is not writable, exit ## --- something is wrong. Probably the user ## has a $HOME/apps dir with wrong permissions. ############################################## if test ! -w "$DIR_HOMEAPPS" then echo " No write permission to directory $DIR_HOMEAPPS. Exiting. " read ANY_KEY_to_exit exit fi ####################################################### ## We set the INSTALLDIR for the particular **********!!! ## application being installed. **********!!! ## ## ** CHECK THIS STATEMENT (esp. release ID) **********!!! ## ** before using this script. **********!!! ####################################################### INSTALLDIR="${DIR_HOMEAPPS}/feAppMenus_2011oct05" ############################################## ## If the $INSTALLDIR already exists, ## exit. ############################################## if test -d "$INSTALLDIR" then echo " The install directory $INSTALLDIR already exits. Aborting the install --- exiting the install script. Rename or remove the existing directory. " read ANY_KEY_to_exit exit fi ############################################## ## Make the $INSTALLDIR for the user, ## if none exists. ############################################## if test ! -d "$INSTALLDIR" then mkdir "$INSTALLDIR" chmod 755 "$INSTALLDIR" fi ################################################# ## The following several statements are to extract ## the data following the 'exit' statement of ## this script (a tar file concatenated to this ## script) --- at user install time --- ## into a file like ## /tmp/TEMP_[appname]_tarfile.tgz ################################################# OUTFILE="/tmp/TEMP_feAppMenus_tarfile.tgz" if test -f "$OUTFILE" then rm "$OUTFILE" fi ####################################################### ## NOTE!!! After all editing is done to this file, ***!!! ## LINENUM var should be set to the number of lines ***!!! ## in this file, PLUS ONE. ***!!! ####################################################### LINENUM=263 tail -n +$LINENUM "$0" > "$OUTFILE" ################################################ ## The following several statements help check ## that the extracted file is proper. ################################################ ## Check the file type of the extracted file: ## Is it recognized as a gzipped tar?? file "$OUTFILE" ## Check the size (bytes) of the extracted file: ## Is it the same as the original gzipped tar file?? ls -l "$OUTFILE" ## Check the table of contents ('t') of the extracted file. tar ztvf "$OUTFILE" ################################################ ## EXTRACT the '.tgz' file into the INSTALLDIR. ################################################ if test -d "$INSTALLDIR" then cd "$INSTALLDIR" tar zxvf "$OUTFILE" fi ############################################## ## Make the $HOME/.freedomenv/feAppMenus/ dir ## and the $HOME/.freedomenv/common/ dir ## for the 'set_FEDIR.shi' file, if the dirs ## do not exist. ## Copy the '.shi' file into the dirs. ############################################## DIR_DOTFREEDOM="$HOME/.freedomenv" if test ! -d "$DIR_DOTFREEDOM" then mkdir "$DIR_DOTFREEDOM" chmod 755 "$DIR_DOTFREEDOM" fi DIR_DOTFREEDOM1="${DIR_DOTFREEDOM}/common" if test ! -d "$DIR_DOTFREEDOM1" then mkdir "$DIR_DOTFREEDOM1" chmod 755 "$DIR_DOTFREEDOM1" fi DIR_DOTFREEDOM2="${DIR_DOTFREEDOM}/feAppMenus" if test ! -d "$DIR_DOTFREEDOM2" then mkdir "$DIR_DOTFREEDOM2" chmod 755 "$DIR_DOTFREEDOM2" fi cp "${INSTALLDIR}/includes_sh/set_FEDIR.shi" "$DIR_DOTFREEDOM1" cp "${INSTALLDIR}/includes_tk/set_feDIR.tki" "$DIR_DOTFREEDOM1" cp "${INSTALLDIR}/includes_sh/set_FEDIR.shi" "$DIR_DOTFREEDOM2" cp "${INSTALLDIR}/includes_tk/set_feDIR.tki" "$DIR_DOTFREEDOM2" ####################################################### ## Make the $HOME/apps/bin/ dir, if none exists. ## And make the soft-link(s) to the main executable(s) ## in that 'bin' dir. ###################################################### DIR_APPS_BIN="$HOME/apps/bin" if test ! -d "$DIR_APPS_BIN" then mkdir "$DIR_APPS_BIN" chmod 755 "$DIR_APPS_BIN" fi if test -f "${DIR_APPS_BIN}/feAppMenus" then rm "${DIR_APPS_BIN}/feAppMenus" fi ln -s -f "${INSTALLDIR}/scripts/feAppMenus" "${DIR_APPS_BIN}/feAppMenus" ############################################################ ## Soft-links to 'xpg', 'fecolorsel', and 'fefontsel' ## may be in $HOME/apps/bin/ because of an FE 'xpg' install ## --- or an 'feHandyTools' install. ## ## To (hopefully) avoid confusion to the user, we only ## make the soft-link(s) to the same-name scripts in ## 'feAppMenus' if the links do not exist already. ############################################################ ## This may STILL cause confusion. May need to remove ## previously existing links and replace with these ## --- since these will probably be more up-to-date. ############################################################ if test ! -f "${DIR_APPS_BIN}/xpg" then ln -s -f "${INSTALLDIR}/scripts/xpg" "${DIR_APPS_BIN}/xpg" fi if test ! -f "${DIR_APPS_BIN}/fecolorsel" then ln -s -f "${INSTALLDIR}/scripts/fecolorsel" "${DIR_APPS_BIN}/fecolorsel" fi if test ! -f "${DIR_APPS_BIN}/fefontsel" then ln -s -f "${INSTALLDIR}/scripts/fefontsel" "${DIR_APPS_BIN}/fefontsel" fi read ANY_KEY_to_exit exit