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 Thu 02 Oct 2014, 12:52
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 Posts_count  
Author Message
mac84

Joined: 18 Feb 2008
Posts: 43

PostPosted: Tue 24 Mar 2009, 18:11    Post_subject:  mybin: script for tinkering
Sub_title: 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:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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