mybin: script for tinkering

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
mac84
Posts: 43
Joined: Mon 18 Feb 2008, 06:32

mybin: script for tinkering

#1 Post by mac84 »

hi there!

This is my script i call 'mybin'

what does it do?

example:
I mainly use muppy 084c. I do alot of tinkering and testing for personal learning. This often means I mess something up along the way so I use live sessions with a setup script I made.

such as I have a packages I've made for installing needed items with out having to remake my pup_XXX.sfs. like my ipw2200patched drivers to set it in monitor mode,lcd brightness, wifi connections, different conky configs, wallpaper, etc...does matter, used right, live or saved I feel @home!

take a look and let me know, this is just something I personally use and will continue to add new elements, I alreadyhave ideas but won't say until I get them working.

... and it's colored for visual confirmation successful green, warning red :)

as configured mybin will
copy itself to /usr/sbin. you can configure it to symlink
create a path to /root/mybin
symlinks /root/mybin to the directory you executed mybin from (like on your usb).

if it is run from another directory after installed, it wil warn you and need confirmation to change the symlink.

Code: Select all

#!/bin/sh 
#mybin
##This script will create a symlink to the running directory
#
# if you run like to run puppy from a usb install this is great
# for having a sort of permanent bin directory working on a live 
# or saved session.
#
# if a symbolic link exist already, it will check if to see if the 
# current directory is already set as $HOME/mybin, if not, it will 
# warn you, show the target for $HOME/mybin and require user input
# of "y" or "n" to continue.
#
#
#a though of |v|@(

clear

#set -x

eN="echo -e \033[0m"
erN="echo -e \033[0m \033[31m"
erB="echo -e \033[0m \033[1m \033[31m"
erbB="echo -e \033[1m \033[31m \033[40m"
egN="echo -e \033[0m \033[32m"
egB="echo -e \033[0m \033[1m \033[32m"
egbB="echo -e \033[1m \033[32m \033[40m"

NM="$0"
MYB=mybin
P2D=$(pwd)
TRGT="/usr/sbin/$MYB"
FLAG="#mybinPATH"
CKPATH=$(cat $HOME/.bashrc | grep '#mybinPATH')

#checks for PATH and symlinks or copies script to /usr/sbin
#
if [ "$CKPATH" = "" ]; then
echo "adding PATH to $HOME/.bashrc"
echo "" >> $HOME/.bashrc
echo "$FLAG" >> $HOME/.bashrc
echo "PATH=$PATH:$HOME/$MYB; export PATH"  >> $HOME/.bashrc
fi
test -e $TRGT
if [ "$?" = "1" ]; then
#link --
echo "creating"
ln -v -s $P2D/$MYB $TRGT

#or copy 
##cp $P2D/$MYB $TRGT
##echo "$P2D/$MYB copied to /usr/sbin"
fi

#mybin setup
${egbB}
echo "------------------------"
echo "|Set $HOME/$MYB symlink|"
echo "running in directory:"; ${eN}
echo "$P2D"
${egbB}
cd

echo "Does $HOME/$MYB exist?"

if [ -d $HOME/$MYB ]; then ${eN}
echo "YES"
$egbB
echo "checking $MYB symlink"

mlink=$(ls -l $HOME/$MYB | awk '{print $10}')

 if [ $mlink == $P2D ]; then ${egB}
 echo "$MYB is symbolic to:"
 ${eN}
 echo "$mlink"
 echo ""
${egbB}
 echo "no need to change"
 echo "EXITING"
 ${eN}

else ${erB}
echo "$MYB is not Symbolic to:"
${eN}
echo "$P2D"
${erN}
echo "$HOME/$MYB links to $link"
${erN}
echo "if you continue, the symlink for $HOME/$MYB will be changed to:"
${egN}
echo "$P2D"
${erN}
echo "y to continue, n to cancel"
echo "(y/n)"
read input

 if [ $input = y ]; then ${erg} 
 ${egbB}
 rm $HOME/$MYB
 ln -f -v -s $P2D $HOME/$MYB
 echo "EXITING"
 ${eN} 
 echo ""
  
 elif [ $input = n ]; then ${erbB}
 echo "User Canceled"
 echo "EXITING"
${eN}


 fi
 
fi

else ${eN} 
echo "no"
${egbB}
ln -v -s $P2D $HOME/$MYB
echo "All Done"
${eN}
echo "EXITING"
${eN}
echo ""

fi

. $HOME/.bashrc

#end of thought

mac84
Posts: 43
Joined: Mon 18 Feb 2008, 06:32

#2 Post by mac84 »

here is a pet I made with mybin

it does not register with petget simply since I have not done a uninstall script.

if you like here it is
Attachments
mybin.pet
(1.27 KiB) Downloaded 309 times

Post Reply