Created
August 25, 2012 05:06
-
-
Save pirogoeth/3461072 to your computer and use it in GitHub Desktop.
I found this while searching my old hard drive.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #zenstaller script for linux - pirogoeth | |
| #copyright 2009-2010 brokendream products | |
| clear | |
| ############################################## | |
| # VARIABLES # | |
| ############################################## | |
| APP= | |
| REV= | |
| ARCHIVE= | |
| BUILD= | |
| ROOT= | |
| BIN= | |
| HASREV= | |
| VER= | |
| SKIPCHECK= | |
| SKIPINT= | |
| DEFPREFIX= | |
| DEVMODE=yes | |
| #i figured i would add this section just as a precaution type thing | |
| #as i know applications like google chrome have a special condition for building | |
| #this is mainly for developers that have to have a special build preparation | |
| #such as export GYP_GENERATORS=make for chrome | |
| #its very helpful also for build dependency installation | |
| #if you (the dev) include a DEPS script that installs all dependencies | |
| #you can put it right in here and have it run. | |
| #here is an example: | |
| ################################### | |
| #export GYP_GENERATORS=make # | |
| #gclient sync # | |
| #gclient runhooks --force # | |
| ################################### | |
| ############################################## | |
| # INTRO # | |
| ############################################## | |
| if [ $SKIPINT == no ] ; then | |
| echo "zenstaller - $APP" | |
| echo "press enter to continue..." | |
| read pause | |
| #sleep 2s | |
| if [ $HASREV == yes ] ; then | |
| echo "current $APP build: $REV" | |
| echo "press enter to continue..." | |
| read pause | |
| #sleep 2s | |
| fi | |
| echo "this script will also remove the application, so keep this script" | |
| echo "only continue if you understand the above" | |
| echo "warning: Do not install $APP in a base system directory (/usr/share/, /, /var/)" | |
| echo "please install in a subdirectory instead. (/usr/share/$APP, /var/apps/$APP)" | |
| echo "press enter to continue..." | |
| read pause | |
| #sleep 2s | |
| else | |
| echo "skipping intro" | |
| echo | |
| sleep 1s | |
| fi | |
| ############################################## | |
| # USER VARS # | |
| ############################################## | |
| echo "please enter a prefix (installation dir)" | |
| echo "default prefix is $DEFPREFIX" | |
| read -p "would you like to use the default prefix? (yes/no) " usedefprefix | |
| if [ $usedefprefix == yes ] ; then | |
| echo "using default prefix" | |
| PREFIX=$DEFPREFIX | |
| USINGDEFPRE=yes | |
| sleep 1s | |
| else | |
| read -p "$USER@PREFIXCHANGE-zensh: " PREFIX;echo "prefix changed to $PREFIX" | |
| echo "using user prefix" | |
| sleep 1s | |
| USINGDEFPRE=no | |
| if [ ! -e $PREFIX ] ; then | |
| read -p "directory does not exist, would you like to create it? " diropt | |
| if [ $diropt == yes ] ; then | |
| mkdir -p $PREFIX | |
| else | |
| echo "aborting." | |
| exit | |
| fi | |
| fi | |
| userpre=$PREFIX | |
| fi | |
| ############################################## | |
| # FILE/FOLDER CHECKS # | |
| ############################################## | |
| if [ $SKIPCHECK == yes ] ; then | |
| echo "skipping check" | |
| echo | |
| clear | |
| else | |
| if [ -d $PREFIX ] ; then | |
| read -p "are you sure you want to set $PREFIX as your installation directory (yes/no) " fcopt | |
| if [ $fcopt == yes ] ; then | |
| echo "$PREFIX will be used" | |
| else | |
| echo "restart installation and choose a different prefix" | |
| echo "removing old prefix" | |
| rm zenstaller.prefix | |
| echo "exiting" | |
| exit | |
| fi | |
| fi | |
| fi | |
| ############################################## | |
| # ARGUMENTS # | |
| ############################################## | |
| optopt=0 | |
| SK=no | |
| clear | |
| until [ $optopt == 1 ] | |
| do | |
| if [ $SK == no ] ; then | |
| if [ $DEVMODE == yes ] ; then | |
| echo "zenstaller dev shell" | |
| else | |
| echo "zenstaller shell" | |
| fi | |
| sleep 2s | |
| echo | |
| echo "type help for commands" | |
| echo "use below prompt to run commands" | |
| echo | |
| SK=yes | |
| fi | |
| read -p "$USER@zensh: " zopt | |
| case $zopt in | |
| install) | |
| ############################################# | |
| # SPECIAL CASE BUILD OPTIONS (DEVS) # | |
| ############################################# | |
| #devs, you know what to do here. | |
| #here, have some lines. | |
| # | |
| # | |
| # | |
| # | |
| # | |
| WD=$(/bin/pwd) | |
| if [ $BUILD == yes ] ; then | |
| echo "this application must be configured and compiled" | |
| echo "application will now be built" | |
| unzip -qq $ARCHIVE -d $WD | |
| cd $ROOT | |
| if [ ! -e ./configure ] ; then | |
| ./autogen.sh --prefix=$PREFIX | |
| else | |
| ./configure --prefix=$userpre | |
| fi | |
| COMPL=$PREFIX | |
| echo "enter your password to install" | |
| sudo make | |
| sudo make install | |
| cd $COMPL | |
| else | |
| echo "no compiling required, continuing" | |
| fi | |
| ############################################## | |
| # ADDITIONAL OPTIONS # | |
| ############################################## | |
| #space for additional install options | |
| # | |
| echo "installed, setting permissions" | |
| cd .. | |
| ############################################## | |
| # PERMISSIONS # | |
| ############################################## | |
| echo "enter password so permissions can be set" | |
| sudo su | |
| chown $USER $PREFIX | |
| chmod 755 $PREFIX | |
| chown -R $USER $PREFIX | |
| chmod -R 755 $PREFIX | |
| exit | |
| echo "permissions set" | |
| sleep 1s | |
| echo "please enter your password to finish installation" | |
| sudo ldconfig | |
| ############################################## | |
| # FINISH # | |
| ############################################## | |
| PREFIX=$DEFPREFIX | |
| ZENST=yes | |
| echo "press enter to finish installation" | |
| read pause | |
| clear | |
| sleep 1s | |
| exit | |
| ;; | |
| remove) read -p "Are you sure you want to remove $APP (yes/no)" REMQ | |
| if [ $REMQ == yes ] ; then | |
| if [ ! $PREFIX == /usr/share/chrome ] ; then | |
| cd $PREFIX | |
| else | |
| cd $DEFPREFIX | |
| PREFIX=$DEFPREFIX | |
| fi | |
| WD=$(/bin/pwd) | |
| if [ ! $WD == $PREFIX ] ; then | |
| echo "somewhere, something got messed up, correcting" | |
| cd $PREFIX | |
| else | |
| echo "starting removal" | |
| rm -vRf $PREFIX | |
| echo "removal completed" | |
| echo "please enter your password to finish installation" | |
| sleep 2s | |
| sudo ldconfig | |
| exit | |
| fi | |
| else | |
| echo "cancelling removal" | |
| fi | |
| ############################################ | |
| # REMOVE ADDITIONAL OPTIONS # | |
| ############################################ | |
| #remove your additional install options (if any) | |
| # | |
| ;; | |
| app) echo "this copy of zenstaller is written for $APP" | |
| if [ $HASREV == yes ] ; then | |
| echo "$APP is currently at build $REV" | |
| fi | |
| ;; | |
| version) echo "this copy of zenstaller is currently at $VER" | |
| echo "zenstaller is written by z/pirogoeth and helpmy360isemo" | |
| ;; | |
| help) echo " zenstaller version 1.0 by z/pirogoeth and helpmy360isemo" | |
| echo " zenstaller - a universal installer for linux" | |
| echo " options:" | |
| echo " install - installs $APP build $REV to $PREFIX" | |
| echo " remove - uninstall $APP from $PREFIX" | |
| echo " version - show current version of zenstaller" | |
| echo " app - display application this copy of zenstaller is written for" | |
| echo " help - this message" | |
| echo " sysreconfig - run ldconfig and update the system" | |
| echo " prefix - show current prefix" | |
| echo " quit - exit zenstaller" | |
| echo " clear - clears screen" | |
| echo " clean - cleans zenstaller files" | |
| echo | |
| if [ $DEVMODE == yes ] ; then | |
| echo " package - make an archive of your code for use with zen" | |
| echo " makeexe - make zen only executable by the the world and group" | |
| echo " set - set a variable from zensh" | |
| echo " more devmode options added as soon as i think of them" | |
| fi | |
| ;; | |
| sysreconfig) echo "please enter your password when prompted" | |
| sudo ldconfig | |
| ;; | |
| prefix) if [ ! $PREFIX == $DEFPREFIX ] ; then | |
| echo "prefix is $PREFIX" | |
| else | |
| echo "current prefix is $DEFPREFIX" | |
| fi | |
| ;; | |
| clear) clear | |
| ;; | |
| clean) rm -rf $ROOT | |
| USINGDEFPREFIX=yes | |
| PREFIX=$DEFPREFIX | |
| echo "cleaned" | |
| ;; | |
| package) if [ $DEVMODE == yes ] ; then | |
| read -p "name of archive: " archname;echo "archive will be renamed $archname" | |
| read -p "name of folder containing files: " foldername | |
| read -p "path: " archpath;echo "archive will be zipped at $archpath" | |
| zip -rv $archpath ./$foldername | |
| mv $foldername.zip $archname | |
| echo "done" | |
| export foldername= | |
| export archpath= | |
| export archname= | |
| else | |
| echo "type help for a list of commands" | |
| fi | |
| ;; | |
| makeexe) if [ $DEVMODE == yes ] ; then | |
| echo "changing binary permissions" | |
| chmod 711 ./zenstaller.sh | |
| echo "done" | |
| else | |
| echo "type help for a list of commands" | |
| fi | |
| ;; | |
| set) if [ $DEVMODE == yes ] ; then | |
| read -p "enter in format: VAR=val: " zenshvar;echo "variable is set" | |
| export $zenshvar | |
| else | |
| echo "type help for a list of commands" | |
| fi | |
| ;; | |
| quit) | |
| optopt=1 | |
| ;; | |
| *);; | |
| esac | |
| done | |
| exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment