This repository has been archived on 2025-06-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
server/gen_hash_link_files.sh

26 lines
462 B
Bash
Executable file

#!/bin/bash
FROM=`realpath $1`; shift
TO=`realpath $1`; shift
if [ -z "$FROM" ] || [ -z "$TO" ]
then
echo "Usage: $0 from to"
exit 1
elif ! [ -d "$FROM" ]
then
echo "$FROM not found"
exit 2
fi
mkdir -p "$TO" || exit 3
rm -rf "$TO" || exit 3
for i in `find "$FROM" -mindepth 1 -type f`
do
FILE=`echo $i | sed "s!^$FROM/!!"`
HASH=`echo -n $FILE | sha384sum | cut -d " " -f 1`
mkdir -p "$TO/$HASH/"
ln -s "$i" "$TO/$HASH/"
done