### for raw view on ios where the ### 1st or 2nd lines are cut off ### by the screen printf "NOTICE: this does NOT package special files like pts/tty devices, anything in /dev, and so on however it CAN package fifo's, named pipes, and sockets, into the archive... continuing in 4 seconds\nnote: sed '5s///g' replaces line 5 with whatever u want\n" # sleep 4 fatal() { echo error: cannot embed "'$path'" into executable: "'$path'" does not exist; exit; } fatal2() { echo error: cannot embed "'$path'" into executable: "'$path'" does not contain any valid files; exit; } fatal3() { echo error: cannot embed "'$path'" into executable: "'$path'" is a "'$type'" file; exit; } fatal4() { echo error: cannot embed "'$1'" into executable: "'$1'" is of type "'$2'"; exit; } strippath() { realpath1=$(readlink -f "$1") pathdir1=$(dirname "$realpath1") pathdir1="$pathdir1/" echo "$pathdir1" } preinitmulti() { mkdir -v Converted ; mkdir -v Converted/"$pathbaseprefix" ; cd Converted/"$pathbaseprefix" printf '%b' '/* */ #include #include #include #include #include #include #include #include #include #include // "look deep into yourself, Clarice" -- Hanibal Lector char findyourself_save_pwd[PATH_MAX]; char findyourself_save_argv0[PATH_MAX]; char findyourself_save_path[PATH_MAX]; char findyourself_path_separator='"'/'"'; char findyourself_path_separator_as_string[2]="/"; char findyourself_path_list_separator[8]=":"; // could be ":; " char findyourself_debug=0; int findyourself_initialized=0; void findyourself_init(char *argv0) { getcwd(findyourself_save_pwd, sizeof(findyourself_save_pwd)); strncpy(findyourself_save_argv0, argv0, sizeof(findyourself_save_argv0)); findyourself_save_argv0[sizeof(findyourself_save_argv0)-1]=0; strncpy(findyourself_save_path, getenv("PATH"), sizeof(findyourself_save_path)); findyourself_save_path[sizeof(findyourself_save_path)-1]=0; findyourself_initialized=1; } int find_yourself(char *result, size_t size_of_result) { char newpath[PATH_MAX+256]; char newpath2[PATH_MAX+256]; assert(findyourself_initialized); result[0]=0; if(findyourself_save_argv0[0]==findyourself_path_separator) { if(findyourself_debug) printf(" absolute path\\n"); realpath(findyourself_save_argv0, newpath); if(findyourself_debug) printf(" newpath=\"%s\"\\n", newpath); if(!access(newpath, F_OK)) { strncpy(result, newpath, size_of_result); result[size_of_result-1]=0; return(0); } else { perror("access failed 1"); } } else if( strchr(findyourself_save_argv0, findyourself_path_separator )) { if(findyourself_debug) printf(" relative path to pwd\\n"); strncpy(newpath2, findyourself_save_pwd, sizeof(newpath2)); newpath2[sizeof(newpath2)-1]=0; strncat(newpath2, findyourself_path_separator_as_string, sizeof(newpath2)); newpath2[sizeof(newpath2)-1]=0; strncat(newpath2, findyourself_save_argv0, sizeof(newpath2)); newpath2[sizeof(newpath2)-1]=0; realpath(newpath2, newpath); if(findyourself_debug) printf(" newpath=\"%s\"\\n", newpath); if(!access(newpath, F_OK)) { strncpy(result, newpath, size_of_result); result[size_of_result-1]=0; return(0); } else { perror("access failed 2"); } } else { if(findyourself_debug) printf(" searching $PATH\\n"); char *saveptr; char *pathitem; for(pathitem=strtok_r(findyourself_save_path, findyourself_path_list_separator, &saveptr); pathitem; pathitem=strtok_r(NULL, findyourself_path_list_separator, &saveptr) ) { if(findyourself_debug>=2) printf("pathitem=\"%s\"\\n", pathitem); strncpy(newpath2, pathitem, sizeof(newpath2)); newpath2[sizeof(newpath2)-1]=0; strncat(newpath2, findyourself_path_separator_as_string, sizeof(newpath2)); newpath2[sizeof(newpath2)-1]=0; strncat(newpath2, findyourself_save_argv0, sizeof(newpath2)); newpath2[sizeof(newpath2)-1]=0; realpath(newpath2, newpath); if(findyourself_debug) printf(" newpath=\"%s\"\\n", newpath); if(!access(newpath, F_OK)) { strncpy(result, newpath, size_of_result); result[size_of_result-1]=0; return(0); } } // end for perror("access failed 3"); } // end else // if we get here, we have tried all three methods on argv[0] and still haven'"'"'t succeeded. Include fallback methods here. return(1); } #include #include #include #include #include #include #include int make_named_socket (const char *filename) { struct sockaddr_un name; int sock; size_t size; /* Create the socket. */ sock = socket (PF_LOCAL, SOCK_DGRAM, 0); if (sock < 0) { perror ("socket"); exit (EXIT_FAILURE); } /* Bind a name to the socket. */ name.sun_family = AF_LOCAL; strncpy (name.sun_path, filename, sizeof (name.sun_path)); name.sun_path[sizeof (name.sun_path) - 1] = '"'\\\0'"'; /* The size of the address is the offset of the start of the filename, plus its length (not including the terminating null byte). Alternatively you can just do: size = SUN_LEN (&name); */ size = (offsetof (struct sockaddr_un, sun_path) + strlen (name.sun_path)); if (bind (sock, (struct sockaddr *) &name, size) < 0) { perror ("bind"); exit (EXIT_FAILURE); } return sock; } int main(int argc, char **argv) { findyourself_init(argv[0]); char newpath[PATH_MAX]; find_yourself(newpath, sizeof(newpath)); if(1 || strcmp(argv[0],newpath)) { } char *dummy = strdup( newpath ); char *dname = dirname( dummy ); printf("Extracting...\\n"); ' > main.c; } objectconvert() { path="$1" && objectfile=$(echo "$path" | sed 's/.*\///') && symbol=$(echo "$path" | tr '\000-\057\072-\100\133-\140\173-\255' '_') && mkdir Converted ; mkdir Converted/"$objectfile" ; cd Converted/"$objectfile" && object=$(objcopy --input binary --output elf64-x86-64 --binary-architecture i386 "$path" "$objectfile".o -v | sed 's/.*to `//' | sed s/\'.*//) && start=$(nm "$object" | sed 's/.* _/_/' | grep "$symbol"start) && size=$(nm "$object" | sed 's/.* _/_/' | grep "$symbol"size) && end=$(nm "$object" | sed 's/.* _/_/' | grep "$symbol"end) && printf '%b' '/* */ #include #include #include #include #include #include #include #include // "look deep into yourself, Clarice" -- Hanibal Lector char findyourself_save_pwd[PATH_MAX]; char findyourself_save_argv0[PATH_MAX]; char findyourself_save_path[PATH_MAX]; char findyourself_path_separator='"'/'"'; char findyourself_path_separator_as_string[2]="/"; char findyourself_path_list_separator[8]=":"; // could be ":; " char findyourself_debug=0; int findyourself_initialized=0; void findyourself_init(char *argv0) { getcwd(findyourself_save_pwd, sizeof(findyourself_save_pwd)); strncpy(findyourself_save_argv0, argv0, sizeof(findyourself_save_argv0)); findyourself_save_argv0[sizeof(findyourself_save_argv0)-1]=0; strncpy(findyourself_save_path, getenv("PATH"), sizeof(findyourself_save_path)); findyourself_save_path[sizeof(findyourself_save_path)-1]=0; findyourself_initialized=1; } int find_yourself(char *result, size_t size_of_result) { char newpath[PATH_MAX+256]; char newpath2[PATH_MAX+256]; assert(findyourself_initialized); result[0]=0; if(findyourself_save_argv0[0]==findyourself_path_separator) { if(findyourself_debug) printf(" absolute path\\n"); realpath(findyourself_save_argv0, newpath); if(findyourself_debug) printf(" newpath=\"%s\"\\n", newpath); if(!access(newpath, F_OK)) { strncpy(result, newpath, size_of_result); result[size_of_result-1]=0; return(0); } else { perror("access failed 1"); } } else if( strchr(findyourself_save_argv0, findyourself_path_separator )) { if(findyourself_debug) printf(" relative path to pwd\\n"); strncpy(newpath2, findyourself_save_pwd, sizeof(newpath2)); newpath2[sizeof(newpath2)-1]=0; strncat(newpath2, findyourself_path_separator_as_string, sizeof(newpath2)); newpath2[sizeof(newpath2)-1]=0; strncat(newpath2, findyourself_save_argv0, sizeof(newpath2)); newpath2[sizeof(newpath2)-1]=0; realpath(newpath2, newpath); if(findyourself_debug) printf(" newpath=\"%s\"\\n", newpath); if(!access(newpath, F_OK)) { strncpy(result, newpath, size_of_result); result[size_of_result-1]=0; return(0); } else { perror("access failed 2"); } } else { if(findyourself_debug) printf(" searching $PATH\\n"); char *saveptr; char *pathitem; for(pathitem=strtok_r(findyourself_save_path, findyourself_path_list_separator, &saveptr); pathitem; pathitem=strtok_r(NULL, findyourself_path_list_separator, &saveptr) ) { if(findyourself_debug>=2) printf("pathitem=\"%s\"\\n", pathitem); strncpy(newpath2, pathitem, sizeof(newpath2)); newpath2[sizeof(newpath2)-1]=0; strncat(newpath2, findyourself_path_separator_as_string, sizeof(newpath2)); newpath2[sizeof(newpath2)-1]=0; strncat(newpath2, findyourself_save_argv0, sizeof(newpath2)); newpath2[sizeof(newpath2)-1]=0; realpath(newpath2, newpath); if(findyourself_debug) printf(" newpath=\"%s\"\\n", newpath); if(!access(newpath, F_OK)) { strncpy(result, newpath, size_of_result); result[size_of_result-1]=0; return(0); } } // end for perror("access failed 3"); } // end else // if we get here, we have tried all three methods on argv[0] and still haven'"'"'t succeeded. Include fallback methods here. return(1); } #include #include #include #include #include #include #include int make_named_socket (const char *filename) { struct sockaddr_un name; int sock; size_t size; /* Create the socket. */ sock = socket (PF_LOCAL, SOCK_DGRAM, 0); if (sock < 0) { perror ("socket"); exit (EXIT_FAILURE); } /* Bind a name to the socket. */ name.sun_family = AF_LOCAL; strncpy (name.sun_path, filename, sizeof (name.sun_path)); name.sun_path[sizeof (name.sun_path) - 1] = '"'\\\0'"'; /* The size of the address is the offset of the start of the filename, plus its length (not including the terminating null byte). Alternatively you can just do: size = SUN_LEN (&name); */ size = (offsetof (struct sockaddr_un, sun_path) + strlen (name.sun_path)); if (bind (sock, (struct sockaddr *) &name, size) < 0) { perror ("bind"); exit (EXIT_FAILURE); } return sock; } int main(int argc, char **argv) { findyourself_init(argv[0]); char newpath[PATH_MAX]; find_yourself(newpath, sizeof(newpath)); if(1 || strcmp(argv[0],newpath)) { } char *dummy = strdup( newpath ); char *dname = dirname( dummy ); printf("Extracting...\\n"); ' > main.c && printf ' // OBJECT START extern char '"$start"'; extern char '"$size"'; // we keep this just in case we ever need it extern char '"$end"'; char * p = &'"$start"'; FILE *fp; chdir(dname); fp = fopen("'"$objectfile"'", ("'"w+"'")); while ( p != &'"$end"' ) fputc(*p++, fp); // credit for fputc(*p++, fp): flawless_snowflake from kik messenger // char y[3]; // strcpy(y, x); fclose(fp); // OBJECT END ' >> main.c ; } objectconvertMulti() { path="$1" && objectfile=$(echo "$path" | tr '\000-\057\072-\100\133-\140\173-\255' '_') && symbol=$(echo "$path" | tr '\000-\057\072-\100\133-\140\173-\255' '_') && object=$(objcopy --input binary --output elf64-x86-64 --binary-architecture i386 "$path" "$2".o -v | sed 's/.*to `//' | sed s/\'.*// | sed 's/ /_/g') && objectlist+="$object " && start=$(nm "$object" | sed 's/.* _/_/' | grep "$symbol"start) && size=$(nm "$object" | sed 's/.* _/_/' | grep "$symbol"size) && end=$(nm "$object" | sed 's/.* _/_/' | grep "$symbol"end) && printf ' // OBJECT START extern char '"$start"'; extern char '"$size"'; // we keep this just in case we ever need it extern char '"$end"'; char * '"a$2"'p = &'"$start"'; FILE *'"a$2"'fp; chdir(dname); ' >> main.c patha5rray=($(echo "$3" | sed s/"\/"/\ /g)) for b in ${patha5rray[@]} do printf '%b' 'mkdir("'"$b"'", 0777); // Simulates the mkdir -p ( mkdir --help: -p, --parents ) argument of the mkdir binary found in /bin/mkdir or /usr/bin/mkdir chdir("'"$b"'"); // Simulates the mkdir -p ( mkdir --help: -p, --parents ) argument of the mkdir binary found in /bin/mkdir or /usr/bin/mkdir ' >> main.c done printf ' '"a$2"'fp = fopen("'"./$4"'", ("'"w+"'")); while ( '"a$2"'p != &'"$end"' ) fputc(*'"a$2"'p++, '"a$2"'fp); // credit for fputc(*p++, fp): flawless_snowflake from kik messenger fclose('"a$2"'fp); chmod("'"./$4"'", '"$5"'); chdir(dname); // OBJECT END ' >> main.c ; } mksymlink() { printf ' // SYMLINK START chdir(dname); ' >> "$orgp2/main.c" patha5rray=($(echo "$1" | sed s/"\/"/\ /g)) for b in ${patha5rray[@]} do printf '%b' 'mkdir("'"$b"'", 0777); // Simulates the mkdir -p ( mkdir --help: -p, --parents ) argument of the mkdir binary found in /bin/mkdir or /usr/bin/mkdir chdir("'"$b"'"); // Simulates the mkdir -p ( mkdir --help: -p, --parents ) argument of the mkdir binary found in /bin/mkdir or /usr/bin/mkdir ' >> "$orgp2/main.c" done printf ' symlink("'"$3"'", "'"$2"'"); chmod("'"./$2"'", '"$4"'); chdir(dname); // SYMLINK END ' >> "$orgp2/main.c" ; } mkfifoC() { printf ' // FIFO START chdir(dname); ' >> main.c patha5rray=($(echo "$1" | sed s/"\/"/\ /g)) for b in ${patha5rray[@]} do printf '%b' 'mkdir("'"$b"'", 0777); // Simulates the mkdir -p ( mkdir --help: -p, --parents ) argument of the mkdir binary found in /bin/mkdir or /usr/bin/mkdir chdir("'"$b"'"); // Simulates the mkdir -p ( mkdir --help: -p, --parents ) argument of the mkdir binary found in /bin/mkdir or /usr/bin/mkdir ' >> main.c done printf ' mkfifo("'"$2"'", '"$3"'); chdir(dname); // FIFO END ' >> main.c ; } mkdirs() { printf ' // MKDIRS START chdir(dname); ' >> main.c patha5rray=($(echo "$1" | sed s/"\/"/\ /g)) for b in ${patha5rray[@]} do printf '%b' 'mkdir("'"$b"'", 0777); // Simulates the mkdir -p ( mkdir --help: -p, --parents ) argument of the mkdir binary found in /bin/mkdir or /usr/bin/mkdir chdir("'"$b"'"); // Simulates the mkdir -p ( mkdir --help: -p, --parents ) argument of the mkdir binary found in /bin/mkdir or /usr/bin/mkdir ' >> main.c done printf ' chdir(dname); // MKDIRS END ' >> main.c ; } chmoddir() { printf ' // CHMODDIR START chdir(dname); chmod("'"$1"'", '"$2"'); chdir(dname); // CHMODDIR END ' >> main.c ; } mksocket() { printf ' // SOCKET START chdir(dname); ' >> main.c patha5rray=($(echo "$1" | sed s/"\/"/\ /g)) for b in ${patha5rray[@]} do printf '%b' 'mkdir("'"$b"'", 0777); // Simulates the mkdir -p ( mkdir --help: -p, --parents ) argument of the mkdir binary found in /bin/mkdir or /usr/bin/mkdir chdir("'"$b"'"); // Simulates the mkdir -p ( mkdir --help: -p, --parents ) argument of the mkdir binary found in /bin/mkdir or /usr/bin/mkdir ' >> main.c done printf ' make_named_socket("'"$2"'"); chmod("'"./$2"'", '"$3"'); chdir(dname); // SOCKET END ' >> main.c ; } mkemptyfile() { printf ' // EMPTY FILE START chdir(dname); ' >> "$orgp2/main.c" patha5rray=($(echo "$1" | sed s/"\/"/\ /g)) for b in ${patha5rray[@]} do printf '%b' 'mkdir("'"$b"'", 0777); // Simulates the mkdir -p ( mkdir --help: -p, --parents ) argument of the mkdir binary found in /bin/mkdir or /usr/bin/mkdir chdir("'"$b"'"); // Simulates the mkdir -p ( mkdir --help: -p, --parents ) argument of the mkdir binary found in /bin/mkdir or /usr/bin/mkdir ' >> "$orgp2/main.c" done printf ' FILE *'"e$4"'fp; '"e$4"'fp = fopen("'"./$2"'", ("'"w+"'")); fclose('"e$4"'fp); chmod("'"./$2"'", '"$3"'); chdir(dname); // EMPTY FILE END ' >> "$orgp2/main.c" ; } compile() { gcc -g main.c "$object" -static && wait } compilemulti() { gcc -g main.c $objectlist -static && wait } compiledebug() { cat ./main.c && gcc -g main.c "$object" -static && wait && echo size of "$path" is $( wc -c < "$path" ) && declare -p path objectfile object start end } compilemultidebug() { cat ./main.c && gcc -g main.c $objectlist -static && wait } fin() { printf ' free( dummy ); printf("Extracted\\n"); return 0; } ' >> main.c } finmulti() { printf ' free( dummy ); printf("Extracted\\n"); return 0; } ' >> main.c } finish() { if [[ -f "$path" || -f "$replacement" ]] ; then cd "$origin" printf "\ package created \n\ " fi } finishdebug() { if [[ -f "$path" || -f "$replacement" ]] ; then pwd printf "\ path= $(ls -Ls ""$path"" )\n\ object= $(ls -Ls ""$object"")\n\ replacement= $(ls -Ls ""$replacement"")\n\ output= $(ls -Ls ./""$object""'bject')\n\ package created \n\ " cd "$origin" fi } finishmulti() { if [[ -f "$path" || -f "$replacement" ]] ; then cd "$origin" printf "\ \n\ package created with $(echo "${objectlist[@]}" | tr ' ' '\n' | wc -l) embeddable files ($(find "$origin"/Converted/Multi | grep "\.o$" | wc -l) recorded files, $(find "$pathreal" -type f | wc -l) physical files, $(find "$pathreal" -type d | wc -l) physical directories, $(echo "${objectlist[@]}" | tr ' ' '\n' | grep -v ^$ | wc -l) non-empty files worth $(echo "${objectlist[@]}" | wc -c) characters, $(echo "${objectlist[@]}" | tr ' ' '\n' | grep ^$ | wc -l) empty, $(echo "${objectlist[@]}" | tr ' ' '\n' | uniq -D | wc -l) duplicates, $(echo "${symlinksreal[@]}" | tr ' ' '\n' | wc -l) symlinks, $(echo "${fifosreal[@]}" | tr ' ' '\n' | wc -l) fifo's (named pipes), and $(echo "${socketsreal[@]}" | tr ' ' '\n' | wc -l) sockets) \n\ " fi } finishmultidebug() { if [[ -f "$path" || -f "$replacement" ]] ; then pwd printf "\ objects= $(ls -L $objectlist | tr "\n" " ")\n\ output= $(ls -Ls ./a.out) \n\ package created \n\ " cd "$origin" fi } replacement="$(whereis "$1" | cut -d ' ' -f2)" origin=$(pwd) # im just going to assume that $0 will NEVER ever contain any of a script's arguments in any cercimstance path="$1" if [[ -d "$path" ]]; then echo "$path" is a directory # stat -c %a ./test/2 # permisions in chmod format # stat -c %F ./test/2 # type stripped="$(strippath "$path" )" pathreal="$(readlink -f "$path" )" pathdir="$(dirname "${pathreal[i]}")" pathdir="$pathdir/" pathbaseprefix=("${pathreal[i]#$pathdir}") mapfile -d '' -t blocksreal < <(find "${pathreal[0]}" '(' -not -type d ')' -not -empty -type b -print0) mapfile -d '' -t characterall < <(find "${pathreal[0]}" '(' -not -type d ')' -not -empty -type c -print0) mapfile -d '' -t dirsreal < <(find "${pathreal[0]}" -type d -print0) mapfile -d '' -t fifosreal < <(find "${pathreal[0]}" '(' -not -type d ')' -not -empty -type p -print0) mapfile -d '' -t filesreal < <(find "${pathreal[0]}" '(' -not -type d ')' -not -empty -type f -print0) mapfile -d '' -t emptyreal < <(find "${pathreal[0]}" '(' -not -type d ')' -empty -type f -print0) mapfile -d '' -t symlinksreal < <(find "${pathreal[0]}" '(' -not -type d ')' -not -empty -type l -print0) mapfile -d '' -t socketsreal < <(find "${pathreal[0]}" '(' -not -type d ')' -not -empty -type s -print0) if [[ -z ${dirsreal[@]} && -z ${fifosreal[@]} && -z ${filesreal[@]} && -z ${emptyreal[@]} && -z ${symlinksreal[@]} ]] ; then fatal2 fi orgp="$(pwd)" preinitmulti orgp2="$(pwd)" for i in ${!filesreal[@]} do pathdir="$(dirname "${filesreal[i]}")" pathdir="$pathdir/" pathbase=("${filesreal[i]#$pathdir}") pathstripped=("${pathdir#$stripped}") objectconvertMulti "${filesreal[i]}" "$i" "$pathstripped" "${pathbase[0]}" "$(stat -c '%05a' "${filesreal[i]}")" echo "${filesreal[i]}" processed done cd "$orgp" for i in ${!emptyreal[@]} do pathdir="$(dirname "${emptyreal[i]}")" pathdir="$pathdir/" pathbase=("${emptyreal[i]#$pathdir}") pathstripped=("${pathdir#$stripped}") mkemptyfile "$pathstripped" "${pathbase[0]}" "$(stat -c '%05a' "${emptyreal[i]}")" "emp$i" echo "${emptyreal[i]}" processed done for i in "${!symlinksreal[@]}" do echo "${symlinksreal[i]}" is a symlink, following... pathdir="$(dirname "${symlinksreal[i]}")" pathdir="$pathdir/" cd "$pathdir" pathbase=("${symlinksreal[i]#$pathdir}") pathstripped=("${pathdir#$stripped}") symlinkorigin+=("${symlinksreal[i]}") symlinkvalue+=("$(readlink "${symlinksreal[i]}")") symlinktypevalue+=("$(stat -c %F "${symlinkvalue[i]}")") # echo "symlinkorigin = ${symlinkorigin[i]}" # echo "symlinkvalue = ${symlinkvalue[i]}" # echo "symlinktypevalue = ${symlinktypevalue[i]}" if [[ ${symlinktypevalue[i]} != "symbolic link" ]] then symlinkfullpath+=("$(readlink -f $(readlink "${symlinksreal[i]}"))") symlinktypepath+=("$(stat -c %F "${symlinkfullpath[i]}")") # echo "symlinkfullpath = ${symlinkfullpath[i]}" # echo "symlinktypepath = ${symlinktypepath[i]}" if [[ ! -e ${symlinkfullpath[i]} ]] ; then fatal4 "${symlinkfullpath[i]}" "${symlinktypepath[i]}" elif [[ -S ${symlinkfullpath[i]} ]] ; then type='socket' fatal4 "${symlinkfullpath[i]}" "${symlinktypepath[i]}" elif [[ -p ${symlinkfullpath[i]} ]] ; then type='named pipe (fifo)' fatal4 "${symlinkfullpath[i]}" "${symlinktypepath[i]}" elif [[ -c ${symlinkfullpath[i]} ]] ; then type='character' fatal4 "${symlinkfullpath[i]}" "${symlinktypepath[i]}" elif [[ -b ${symlinkfullpath[i]} ]] ; then type='block' fatal4 "${symlinkfullpath[i]}" "${symlinktypepath[i]}" elif [[ ! -s ${symlinkfullpath[i]} ]] ; then type='empty' pathdir="$(dirname "${symlinkfullpath[i]}")" pathdir="$pathdir/" pathbase=("${symlinkfullpath[i]#$pathdir}") pathstripped=("${pathdir#$stripped}") mkemptyfile "$pathstripped" "${pathbase[0]}" "$(stat -c '%05a' "${symlinkfullpath[i]}")" "sym$i" echo "${symlinkfullpath[i]}" processed # fatal4 "${symlinkfullpath[i]}" "${symlinktypepath[i]}" # elif [[ -f $path ]] ; then # type='regular' # fatal4 fi else symlinkfullpath+=("null") fi cd "$orgp" done for i in ${!symlinkvalue[@]} do cd "$orgp" echo "${symlinkorigin[i]} is a symlink to ${symlinkvalue[i]} (${symlinkfullpath[i]}) with type ${symlinktypevalue[i]}" pathdir="$(dirname "${symlinkorigin[i]}")" pathdir="$pathdir/" cd "$pathdir" pathbase=("${symlinkorigin[i]#$pathdir}") pathstripped=("${pathdir#$stripped}") mksymlink "$pathstripped" "${pathbase[0]}" "${symlinkvalue[i]}" "$(stat -c '%05a' "${symlinkorigin[i]}")" echo "${symlinkorigin[i]}" processed cd "$orgp" done cd "$orgp2" for i in ${!fifosreal[@]} do pathdir="$(dirname "${fifosreal[i]}")" pathdir="$pathdir/" pathbase=("${fifosreal[i]#$pathdir}") pathstripped=("${pathdir#$stripped}") mkfifoC "$pathstripped" "${pathbase[0]}" "$(stat -c '%05a' "${fifosreal[i]}")" echo "${fifosreal[i]}" processed done for i in ${!socketsreal[@]} do pathdir="$(dirname "${socketsreal[i]}")" pathdir="$pathdir/" pathbase=("${socketsreal[i]#$pathdir}") pathstripped=("${pathdir#$stripped}") mksocket "$pathstripped" "${pathbase[0]}" "$(stat -c '%05a' "${socketsreal[i]}")" echo "${socketsreal[i]}" processed done for i in ${!dirsreal[@]} do pathdir="$(dirname "${dirsreal[i]}")" if [[ $pathdir = "/" ]] then pathdir= fi pathdir="$pathdir/" pathbase=("${dirsreal[i]#$pathdir}") pathstripped=("${pathdir#$stripped}") if [[ $pathstripped = "/" ]] then pathstripped= fi mkdirs "$pathstripped$pathbase" echo "${dirsreal[i]}" processed done for i in ${!dirsreal[@]} do pathdir="$(dirname "${dirsreal[i]}")" if [[ $pathdir = "/" ]] then pathdir= fi pathdir="$pathdir/" pathbase=("${dirsreal[i]#$pathdir}") pathstripped=("${pathdir#$stripped}") if [[ $pathstripped = "/" ]] then pathstripped= fi chmoddir "$pathstripped$pathbase" "$(stat -c '%05a' "${dirsreal[i]}")" echo "$pathstripped$pathbase" processed done finmulti compilemulti finishmulti exit elif [ "$(printf '%s\n' "$path" | grep -e ^"/")" ]; then if [[ -L $path ]] ; then echo $path is a symlink, following... path="$(readlink $path)" if [[ ! -e $path ]] ; then fatal elif [[ -S $path ]] ; then type='socket' fatal3 elif [[ -p $path ]] ; then type='named pipe (fifo)' fatal3 elif [[ -c $path ]] ; then type='character' fatal3 elif [[ -b $path ]] ; then type='block' fatal3 elif [[ ! -s $path ]] ; then type='empty' fatal3 # elif [[ -f $path ]] ; then # type='regular' # fatal3 fi elif [[ ! -e $path ]] ; then fatal elif [[ -S $path ]] ; then type='socket' fatal3 elif [[ -p $path ]] ; then type='named pipe (fifo)' fatal3 elif [[ -c $path ]] ; then type='character' fatal3 elif [[ -b $path ]] ; then type='block' fatal3 elif [[ ! -s $path ]] ; then type='empty' fatal3 # elif [[ -f $path ]] ; then # type='regular' # fatal3 fi path="$path" elif [ "$(printf '%s\n' "$path" | grep -e ^"./" -e ^"../")" ]; then if [[ -L $path ]] ; then echo $path is a symlink, following... symlinkvalue="$(readlink $path)" symlinkfullpath="$(readlink -f "$(readlink $path)")" stat -c %F "$symlinkfullpath" declare -p symlinkfullpath symlinkvalue path=$symlinkfullpath if [[ ! -e $path ]] ; then fatal elif [[ -S $path ]] ; then type='socket' fatal3 elif [[ -p $path ]] ; then type='named pipe (fifo)' fatal3 elif [[ -c $path ]] ; then type='character' fatal3 elif [[ -b $path ]] ; then type='block' fatal3 elif [[ ! -s $path ]] ; then type='empty' fatal3 # elif [[ -f $path ]] ; then # type='regular' # fatal3 fi elif [[ ! -e $path ]] ; then fatal elif [[ -S $path ]] ; then type='socket' fatal3 elif [[ -p $path ]] ; then type='named pipe (fifo)' fatal3 elif [[ -c $path ]] ; then type='character' fatal3 elif [[ -b $path ]] ; then type='block' fatal3 elif [[ ! -s $path ]] ; then type='empty' fatal3 # elif [[ -f $path ]] ; then # type='regular' # fatal3 fi echo converting "$path" to absolute path pathfile=("$(find "$path" -type f)") pathfilefull+=("$(readlink -f "${pathfile[i]}")") echo converted to absolute path path="$pathfilefull" elif [[ -f "$replacement" ]]; then : > /dev/null else fatal fi if [[ -f "$path" ]] ; then objectconvert "$path" fin compile finish exit elif [[ -f "$replacement" ]] ; then echo Warning: "$path" does not exist however "$replacement" does, using "$replacement" objectconvert "$replacement" fin compile finish exit else fatal fi