From b33ab63436278c7de3c1dd6e0371d9e28788cfb8 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Sun, 2 Aug 2015 17:52:06 -0400 Subject: [PATCH] hoisting the alias definitions up into a function, so we can track them and eventually unload all of them automatically. added a similar method for exported variables, also completely simplistic at this point. all usages that seemed appropriate for setting up using the new alias function have been moved over, and things are still working as far as i can tell at this point up until the point when things break which is probably pretty soon, but oh well, progress... --- customizing/fred/fred_common.alias | 4 +- customizing/mik/mik.alias | 16 ++-- scripts/buildor/gffs_builders.sh | 2 +- scripts/core/common.alias | 102 ++++++++++++------------ scripts/core/functions.sh | 42 ++++++++++ scripts/core/generate_aliases.pl | 4 +- scripts/security/create_certificates.sh | 12 +-- 7 files changed, 112 insertions(+), 70 deletions(-) diff --git a/customizing/fred/fred_common.alias b/customizing/fred/fred_common.alias index 63ba8eac..743634a6 100644 --- a/customizing/fred/fred_common.alias +++ b/customizing/fred/fred_common.alias @@ -3,8 +3,8 @@ # based on some of the mount configurations available at home or abroad. # moo and unmoo mount the local folders i use most. -alias moo='check_mount /z/stuffing ; check_mount /z/walrus ; check_mount /z/chunky ; check_mount /z/fredgrid' -alias unmoo='sudo umount /z/stuffing ; sudo umount /z/walrus ; sudo umount /z/chunky ; sudo umount /z/fredgrid' +define_yeti_alias moo='check_mount /z/stuffing ; check_mount /z/walrus ; check_mount /z/chunky ; check_mount /z/fredgrid' +define_yeti_alias unmoo='sudo umount /z/stuffing ; sudo umount /z/walrus ; sudo umount /z/chunky ; sudo umount /z/fredgrid' # load in the gffs build scripts. source "$FEISTY_MEOW_SCRIPTS/buildor/gffs_builders.sh" diff --git a/customizing/mik/mik.alias b/customizing/mik/mik.alias index ee3602ea..e21f7d5c 100644 --- a/customizing/mik/mik.alias +++ b/customizing/mik/mik.alias @@ -1,13 +1,13 @@ -alias lsd='ls -l' -alias h='history' -alias dw='du | grep Waves' -alias rm='rm' -alias d1='du --max-depth=1' -alias df='/bin/df' +define_yeti_alias lsd='ls -l' +define_yeti_alias h='history' +define_yeti_alias dw='du | grep Waves' +define_yeti_alias rm='rm' +define_yeti_alias d1='du --max-depth=1' +define_yeti_alias df='/bin/df' -alias rebob='chowngrp -R bob /home/bob ; chowngrp -R bob /home/games ; chowngrp -R bob /home/archives ; chowngrp -R bob /Data ; chowngrp -R bob /fatty ; chowngrp -R bob /srv/ftp ' +define_yeti_alias rebob='chowngrp -R bob /home/bob ; chowngrp -R bob /home/games ; chowngrp -R bob /home/archives ; chowngrp -R bob /Data ; chowngrp -R bob /fatty ; chowngrp -R bob /srv/ftp ' -alias ipod=gtkpod +define_yeti_alias ipod=gtkpod diff --git a/scripts/buildor/gffs_builders.sh b/scripts/buildor/gffs_builders.sh index 21dbb59c..af7273e3 100644 --- a/scripts/buildor/gffs_builders.sh +++ b/scripts/buildor/gffs_builders.sh @@ -3,7 +3,7 @@ source "$FEISTY_MEOW_SCRIPTS/core/functions.sh" #hmmm: if this works well, we can use it in lots of places. -alias BAIL_ON_FAIL='if [ $? -ne 0 ]; then echo "A problem occurred. $msg"; return 1; fi' +define_yeti_alias BAIL_ON_FAIL='if [ $? -ne 0 ]; then echo "A problem occurred. $msg"; return 1; fi' function build_gffs() { diff --git a/scripts/core/common.alias b/scripts/core/common.alias index 7b8d3cad..0868f232 100644 --- a/scripts/core/common.alias +++ b/scripts/core/common.alias @@ -12,87 +12,87 @@ # a list of core aliases for feisty meow codebase. # repurposes certain commands that feisty meow does a little differently. -alias cls='clear_colormap; clear' -alias copy='\cp -i -v ' -alias cp='\cp -i -v ' -alias cvs='perl $FEISTY_MEOW_SCRIPTS/rev_control/cvs_fix.pl' -alias del='perl $FEISTY_MEOW_SCRIPTS/files/safedel.pl' -alias deltree='perl $FEISTY_MEOW_SCRIPTS/files/safedel.pl' -alias df='\df -mh' -alias dir='perl $FEISTY_MEOW_SCRIPTS/files/summing_dir.pl' -alias du='\du -h' -alias erase='perl $FEISTY_MEOW_SCRIPTS/files/safedel.pl' +define_yeti_alias cls='clear_colormap; clear' +define_yeti_alias copy='\cp -i -v ' +define_yeti_alias cp='\cp -i -v ' +define_yeti_alias cvs='perl $FEISTY_MEOW_SCRIPTS/rev_control/cvs_fix.pl' +define_yeti_alias del='perl $FEISTY_MEOW_SCRIPTS/files/safedel.pl' +define_yeti_alias deltree='perl $FEISTY_MEOW_SCRIPTS/files/safedel.pl' +define_yeti_alias df='\df -mh' +define_yeti_alias dir='perl $FEISTY_MEOW_SCRIPTS/files/summing_dir.pl' +define_yeti_alias du='\du -h' +define_yeti_alias erase='perl $FEISTY_MEOW_SCRIPTS/files/safedel.pl' # elaborate replacement for filesystem explorer command, which we have # shortened to "exp". if [ "$OS" != "Windows_NT" ]; then if [ -n "$IS_DARWIN" ]; then # case for mac os x. - alias exp='open' + define_yeti_alias exp='open' elif [ ! -z "$(which nautilus 2>/dev/null)" ]; then # we prefer nautilus if available. - alias exp='nautilus' + define_yeti_alias exp='nautilus' else # last ditch is konqueror browser. - alias exp='konqueror' + define_yeti_alias exp='konqueror' fi else # windows gets routed to our helpful script instead. - alias exp="bash $FEISTY_MEOW_SCRIPTS/winders/exploder.sh" + define_yeti_alias exp="bash $FEISTY_MEOW_SCRIPTS/winders/exploder.sh" fi # re-use work we did on 'exp' macro for the longer windows command. -alias explorer=exp -alias i=inventory -alias l='perl $FEISTY_MEOW_SCRIPTS/files/summing_dir.pl' -alias ls='ls -HhFC $color_add' -alias lsd='ls -hl' -alias md='mkdir' -alias more='less' -alias move='mv -i -v ' -alias mv='\mv -i -v ' -alias notepad='gedit' -alias pwd="/bin/pwd|sed -e 's/^\/home\/$USER/~/'" -alias rd='perl $FEISTY_MEOW_SCRIPTS/files/zapdirs.pl' -alias ren='\mv -v -i ' -alias rm='perl $FEISTY_MEOW_SCRIPTS/files/safedel.pl' -alias rmdir='perl $FEISTY_MEOW_SCRIPTS/files/zapdirs.pl' -alias s='echo "##############"' -alias path='echo $PATH' -alias whence=which +define_yeti_alias explorer=exp +define_yeti_alias i=inventory +define_yeti_alias l='perl $FEISTY_MEOW_SCRIPTS/files/summing_dir.pl' +define_yeti_alias ls='ls -HhFC $color_add' +define_yeti_alias lsd='ls -hl' +define_yeti_alias md='mkdir' +define_yeti_alias more='less' +define_yeti_alias move='mv -i -v ' +define_yeti_alias mv='\mv -i -v ' +define_yeti_alias notepad='gedit' +define_yeti_alias pwd="/bin/pwd|sed -e 's/^\/home\/$USER/~/'" +define_yeti_alias rd='perl $FEISTY_MEOW_SCRIPTS/files/zapdirs.pl' +define_yeti_alias ren='\mv -v -i ' +define_yeti_alias rm='perl $FEISTY_MEOW_SCRIPTS/files/safedel.pl' +define_yeti_alias rmdir='perl $FEISTY_MEOW_SCRIPTS/files/zapdirs.pl' +define_yeti_alias s='echo "##############"' +define_yeti_alias path='echo $PATH' +define_yeti_alias whence=which ############## # some aliases that are just generally nice to have. -alias aliases=alias -alias calc='kcalc' -alias cd..='\cd ..' -alias cd...='\cd ../..' -alias cd....='\cd ../../..' -alias cd.....='\cd ../../../..' -alias mo='less' -alias np='gvim' -alias up='cd ..' +define_yeti_alias aliases=alias +define_yeti_alias calc='kcalc' +define_yeti_alias cd..='\cd ..' +define_yeti_alias cd...='\cd ../..' +define_yeti_alias cd....='\cd ../../..' +define_yeti_alias cd.....='\cd ../../../..' +define_yeti_alias mo='less' +define_yeti_alias np='gvim' +define_yeti_alias up='cd ..' ############## # extended aliases for meta-operations. -alias dvd_rip='vobcopy -m' -alias blu_rip='echo "what would this command be?"' -alias mplayer='\mplayer -ao arts' -alias play='bash $FEISTY_MEOW_SCRIPTS/multimedia/sound_play.sh' +define_yeti_alias dvd_rip='vobcopy -m' +define_yeti_alias blu_rip='echo "what would this command be?"' +define_yeti_alias mplayer='\mplayer -ao arts' +define_yeti_alias play='bash $FEISTY_MEOW_SCRIPTS/multimedia/sound_play.sh' ############## # some really eccentric feisty meow aliases... # says goodbye when leaving a shell. -alias bye='. $FEISTY_MEOW_SCRIPTS/users/goodbye.sh' -alias cputemp='acpi -t' +define_yeti_alias bye='. $FEISTY_MEOW_SCRIPTS/users/goodbye.sh' +define_yeti_alias cputemp='acpi -t' # makes root user's home directory's permissions right. -alias reroot='chown -R root:root /root' +define_yeti_alias reroot='chown -R root:root /root' # yes, these are really helpful... -alias whoareyou='echo -e "Hello, I am a computer named $(hostname)\nand I'\''m very pleased to meet you."' -alias whereami='echo whoa dude, try not to think about it...' -alias why='echo We all wonder what the point of the universe is at times. If you figure it all out, please write us.' +define_yeti_alias whoareyou='echo -e "Hello, I am a computer named $(hostname)\nand I'\''m very pleased to meet you."' +define_yeti_alias whereami='echo whoa dude, try not to think about it...' +define_yeti_alias why='echo We all wonder what the point of the universe is at times. If you figure it all out, please write us.' # done with loading up regular aliases now... diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 6415adbe..535f5ecd 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -488,6 +488,48 @@ if [ -z "$skip_all" ]; then ############## +# new breed of definer functions goes here. still in progress. + + # defines an alias and remembers that this is a new or modified definition. + # if the feisty meow codebase is unloaded, then so are all the aliases that + # were defined. + function define_yeti_alias() + { +# if alias exists already, save old value for restore, +# otherwise save null value for restore, +# have to handle unaliasing if there was no prior value of one +# we newly defined. +# add alias name to a list of feisty defined aliases. + +#hmmm: first implem, just do the alias and get that working... +alias "${@}" + + +return 0 + } + + # defines a variable within the feisty meow environment and remembers that + # this is a new or modified definition. if the feisty meow codebase is + # unloaded, then so are all the variables that were defined. + # this function always exports the variables it defines. + function define_yeti_variable() + { +# if variable exists already, save old value for restore, +# otherwise save null value for restore, +# have to handle unsetting if there was no prior value of one +# we newly defined. +# add variable name to a list of feisty defined variables. + +#hmmm: first implem just sets it up and exports the variable. +# i.e., this method always exports. +export "${@}" + + +return 0 + } + + ############## + function function_sentinel() { return 0; } if [ ! -z "$SHELL_DEBUG" ]; then echo "feisty meow function definitions done."; fi diff --git a/scripts/core/generate_aliases.pl b/scripts/core/generate_aliases.pl index 40f555e9..a96fae3f 100644 --- a/scripts/core/generate_aliases.pl +++ b/scripts/core/generate_aliases.pl @@ -47,7 +47,7 @@ sub make_bash_alias { #print "alias became $aliasname\n"; local($source_dir) = shift(@_); #print "bash alias is $aliasname, dir is $source_dir\n"; - print she "alias $aliasname=\"bash $source_dir/$full_alias.sh\"\n"; + print she "define_yeti_alias $aliasname=\"bash $source_dir/$full_alias.sh\"\n"; } # makes an alias for a perl script given the alias name. @@ -58,7 +58,7 @@ sub make_perl_alias { #print "alias became $aliasname\n"; local($source_dir) = shift(@_); #print "perl alias is $aliasname, dir is $source_dir\n"; - print she "alias $aliasname=\"perl $source_dir/$full_alias.pl\"\n"; + print she "define_yeti_alias $aliasname=\"perl $source_dir/$full_alias.pl\"\n"; } # given a directory, this returns an array of all the filenames found therein. diff --git a/scripts/security/create_certificates.sh b/scripts/security/create_certificates.sh index 72100fd8..af8daaf9 100644 --- a/scripts/security/create_certificates.sh +++ b/scripts/security/create_certificates.sh @@ -1,12 +1,12 @@ filename="$1"; shift -alias="$1"; shift -if [ -z "$filename" -o -z "$alias" ]; then - echo This script needs a base portion for the certificate filename to create - echo and the alias for the certificate. +cert_alias="$1"; shift +if [ -z "$filename" -o -z "$cert_alias" ]; then + echo "This script needs a base portion for the certificate filename to create" + echo "and the alias (or short name) for the certificate." echo For example: echo -e "\t$(basename $0 .sh) DrakeKey \"DrakeContainer\"" - echo would create DrakeKey.pem and DrakeKey.pfx with an alias of DrakeContainer. + echo would create DrakeKey.pem and DrakeKey.pfx with a cert alias of DrakeContainer. exit 1 fi @@ -15,7 +15,7 @@ openssl req -x509 -nodes -days 3650 \ -newkey rsa:1024 -keyout ${filename}.pem -out ${filename}.pem # export the PEM to a PFX file. -openssl pkcs12 -export -out ${filename}.pfx -in ${filename}.pem -name "$alias" +openssl pkcs12 -export -out ${filename}.pfx -in ${filename}.pem -name "$cert_alias" # export the PEM to a DER certificate file. openssl x509 -inform pem -in ${filename}.pem -outform der -out ${filename}.cer -- 2.34.1