#!/bin/sh ## ## SCRIPT: 02_extractFromSelf_code_forCat2tarfile_ofXpgDirs.sh ## ## PURPOSE: Extracts all the bytes after the bottom of this script, that is, ## after the last statement, 'exit'. ## Puts the bytes into a temp file. Then unzips and untars that '.tgz' ## file into a specified install directory, in $HOME/apps. ## Finishes by copying a few files into a $HOME/.freedomenv dir and ## then making a few links in $HOME/apps/bin. ## ## Makes directories of $HOME as needed --- $HOME/apps and $HOME/apps/bin. ## ## To do the 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 LINENUM number, if need be!!! ##********************************************************************************** ## ******* ALSO!!! Set the yyyymmdd DATE, that you want to use, in INSTALLDIR!!!!!!! ##********************************************************************************** ## ## 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 of making the self-extracting install script ## (continued onto a 2nd line): ## ## 1) cat 02_extractFromSelf_code_forCat2tarfile_ofXpgDirs.sh xpg_yyyymmmdd.tar.gz \ ## > extractFromSelf_XpgFiles_yyyymmmdd.sh ## ## Let's say yyyymmdd is 2010aug27. ## For the user to do an install, ## after download of extractFromSelf_XpgFiles_2010aug27.sh, user does ## 2) chmod 755 extractFromSelf_XpgFiles_2010aug27.sh ## ## Then, for the user to do an install, from any dir, run ## 3) ./extractFromSelf_XpgFiles_2010aug27.sh ## ## That self-extracting 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 in /tmp. ## Tnen the script untars the temp file into the install directory, in the ## 'apps' directory of the user's home directory --- and makes a soft-link ## to a few executables (scripts), in the $HOME/apps/bin directory. ## ## Started: 2010may02 For NautilusScriptsFE install build. ## Changed: 2010aug27 Changed to create an 'xpg' 2010aug27 install file. ## Changed: 2010aug30 Changed to create an 'xpg' 2010aug30 install file. ## Changed: 2010sep03 Added statements to cp 'set_FEDIR.shi' file from ## 'includes_sh' dir to $HOME/.freedomenv/1/, after ## making the latter dir. Chgd LINENUM accordingly. ## Changed: 2010sep07 Added statements to cp 'set_feDIR.tki' file from ## 'includes_tk' dir to $HOME/.freedomenv/1/, after ## making the latter dir. Chgd LINENUM accordingly. ## Changed: 2011jan31 Added statements to make $HOME/apps/bin if need be, ## and make soft-links to main scripts via 'ln -s'. ## Changed: 2011may19 Chgd $HOME/.freedomenv/1/ to $HOME/.freedomenv/feXpg/. ## Changed: 2011jul31 Chgd $HOME/.freedomenv/feXpg/ to $HOME/.freedomenv/common/. ## FOR TESTING: (show statements as they execute, during an install-build) set -x ############################################## ## Make the $HOME/apps dir for the user, ## if none exists. ############################################## 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}/feXpg_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 extract the bottom ## 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_Xpg_tarfile.tgz" ##**************************************************** ## NOTE!!! After all editing is done to this file,!!!! ## LINENUM var should be set to the number of lines!!! ## in this file, PLUS ONE. *************************** ## (Maybe someday we will set this automatically,!!! ## by reading $0 and finding '^exit$'.) !!! ##**************************************************** LINENUM=247 tail -n +$LINENUM "$0" > "$OUTFILE" ###################################################### ## The following several statements help check the ## extracted file, to see that it contains the proper ## data. ###################################################### ## 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. ## Do all directories and files have proper permissions? ## For example, do directories have read-write (5) permissions? tar ztvf "$OUTFILE" ###################################################### ## EXTRACT THE temp 'tar.gz' FILE INTO THE INSTALL DIR. ###################################################### if test -d "$INSTALLDIR" then cd "$INSTALLDIR" tar zxvf "$OUTFILE" fi ################################################## ## Make the $HOME/.freedomenv/common/ and ## $HOME/.freedomenv/feXpg/ dirs for the ## 'set_FEDIR.shi' and 'set_feDIR.tki' files, ## if none exists. ## Copy the '.shi' and '.tki' files into that dir. ################################################## 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}/feXpg" 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 ln -s -f "${INSTALLDIR}/scripts/xpg" "${DIR_APPS_BIN}/xpg" ln -s -f "${INSTALLDIR}/scripts/fecolorsel" "${DIR_APPS_BIN}/fecolorsel" ln -s -f "${INSTALLDIR}/scripts/fefontsel" "${DIR_APPS_BIN}/fefontsel" read ANY_KEY_to_exit exit