Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- LOGDIR="${HOME}/SrcDS_Ln_Log";
- while getopts "d:" optname
- do
- case "$optname" in
- "d")
- LOGDIR="$OPTARG";
- ;;
- "?")
- echo "Unknown option $OPTARG";
- ;;
- esac
- done
- LOGFILE="${LOGDIR}/SrcDS_Linker_$(date +"%F")-$(date +"%T").log";
- args=("$@");
- nr=$#-1;
- MAKE=${args[$nr]};
- if [ ! -d "$LOGDIR" ]; then
- mkdir -p $LOGDIR;
- fi
- echo "Logfile: ${LOGFILE}";
- echo "===LOG START===" >> $LOGFILE;
- self=`basename "$0"`;
- case $MAKE in
- "create")
- find ./* |while read FILENAME
- do
- i=${FILENAME};
- o=`echo ${i}|rev`;
- l=`echo ${o%.}|rev`;
- j=`echo ${l}|rev`;
- k=`echo ${j%.*}|rev`;
- c=`basename "$l"`;
- case $l in
- "/$self")
- echo -e '\E[32;40m'"Omitting $self";tput sgr0;
- echo "Omitting $self" >> $LOGFILE;
- ;;
- *.*)
- #Commented out for a little lett console print, will still be logged.
- #echo "Make Symlink from FILE- $i ---> .$(echo ${l%.*} | tr [:lower:] [:upper:]).$k";
- ln -s "./$c" ".$(echo ${l%.*} | tr [:lower:] [:upper:]).$k";
- echo "./$c .$(echo ${l%.*} | tr [:lower:] [:upper:]).$k" >> $LOGFILE;
- ;;
- *)
- echo -e 'Make Symlink from \E[34m\E[34mDIR--'`tput sgr0` "$i ---> .`echo "$l" | tr [:lower:] [:upper:]`";
- ln -s "./$c" "`echo .$l | tr [:lower:] [:upper:]`";
- echo "./$c `echo .$l | tr [:lower:] [:upper:]`" >> $LOGFILE;
- ;;
- esac
- done
- echo "===LOG END===" >> $LOGFILE;
- ;;
- "test")
- echo "Test Run!!!!!!" >> $LOGFILE;
- find ./* |while read FILENAME
- do
- i=${FILENAME};
- o=`echo ${i}|rev`;
- l=`echo ${o%.}|rev`;
- j=`echo ${l}|rev`;
- k=`echo ${j%.*}|rev`;
- c=`basename "$l"`;
- case $l in
- "/$self")
- echo -e '\E[32;40m'"Omitting $self";tput sgr0;
- echo "Omitting $self" >> $LOGFILE;
- ;;
- *.*)
- echo "FILE- $i" ".$(echo ${l%.*} | tr [:lower:] [:upper:]).$k";
- echo "./$c .$(echo ${l%.*} | tr [:lower:] [:upper:]).$k" >> $LOGFILE;
- ;;
- *)
- echo -e '\E[34m\E[34mDIR--'`tput sgr0` "$i .`echo "$l" | tr [:lower:] [:upper:]`";
- echo "./$c $(echo .$l | tr [:lower:] [:upper:])" >> $LOGFILE;
- ;;
- esac
- done
- echo "===LOG END===" >> $LOGFILE;
- ;;
- *)
- echo -e "\v";
- echo '****************************************************************************************'
- echo "Usage: ./`basename "$0"` create|test [-d FILE]";
- echo -e "\n\n\"create\" starts the creation of symbolic links in current directory.";
- echo "It will go into subfolders and continue there until all subdirectories are included";
- echo -e "Do no use create without testing first.\v";
- echo "\"test\" will list all the files and folders that will be linked";
- echo "it will show the TARGET and LINK names and placement.";
- echo "Recomended to use before using the create function.";
- echo "Also recomended to read the log output of this before";
- echo -e "using the create function\v\v";
- echo "This is ment for usage with the GNU/Linux and Src Dedicated Server";
- echo "\"Failed to load \$include\" problem. This problem is caused due";
- echo "to Linux being case sensitive and the server looking for files and";
- echo "folders that are in UPPERCASE letters tho they have been downloaded";
- echo "and named in lowercase letters. This means they are not the same files";
- echo -e "as the ones being looked for.\n\n";
- echo "This little script is ment to correct this by making";
- echo "symbolic links with the right name to the oridginale file.";
- echo -e "\n\t*******************************************************************";
- echo -e "\t| Log files will be created in the directory:";
- echo -e "\t| $LOGDIR";
- echo -e "\t| The file will be saved as";
- echo -e "\t| $LOGFILE";
- echo -e "\t| To change this use the \"-d /path/to/logdir\" option.\n\t|";
- echo -e "\t| Make sure you have "'\E[32mwrite permissions' `tput sgr0` "for this folder and file";
- echo '****************************************************************************************'
- ;;
- esac
- exit 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement