Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 23 Sep 2014, 00:24
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
mybin: script for tinkering
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [2 Posts]  
Author Message
mac84

Joined: 18 Feb 2008
Posts: 43

PostPosted: Tue 24 Mar 2009, 18:11    Post subject:  mybin: script for tinkering
Subject description: set permant path on usb or any folder to /root/mybin
 

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 Smile

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:

#!/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
Back to top
View user's profile Send private message 
mac84

Joined: 18 Feb 2008
Posts: 43

PostPosted: Tue 24 Mar 2009, 18:47    Post subject:  

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
mybin.pet
Description 
pet

 Download 
Filename  mybin.pet 
Filesize  1.27 KB 
Downloaded  188 Time(s) 
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [2 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0515s ][ Queries: 12 (0.0045s) ][ GZIP on ]