mirror of
https://github.com/kevinveenbirkenbach/linux-image-manager.git
synced 2024-11-22 07:01:03 +01:00
created make-home-cloud-compatible.sh
This commit is contained in:
parent
50d5b43744
commit
df11df9f25
30
scripts/data/make-home-cloud-compatible.sh
Normal file
30
scripts/data/make-home-cloud-compatible.sh
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# This script syncronizes home folders with the cloud
|
||||||
|
# @param $1 clouddomain.tld
|
||||||
|
#
|
||||||
|
directories=("Documents" "Pictures" "Music" "Books" "Videos");
|
||||||
|
for folder in "${directories[@]}"; do
|
||||||
|
home_directory="$HOME/$folder";
|
||||||
|
cloud_directory="$HOME/Clouds/$1/$folder";
|
||||||
|
if [ -L "$home_directory" ]
|
||||||
|
then
|
||||||
|
if [ "$(readlink -f "$home_directory")" == "$(realpath "$cloud_directory")" ]
|
||||||
|
then
|
||||||
|
"Folder $home_directory is allready symlinked with $cloud_directory. Skipped.";
|
||||||
|
else
|
||||||
|
"ERROR: Folder $home_directory links to a wrong target. Solve manually!" && exit 1;
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ -d "$cloud_directory" ]
|
||||||
|
then
|
||||||
|
mv -v "$home_directory/"* "$cloud_directory/" &&
|
||||||
|
rmdir -v "$home_directory" &&
|
||||||
|
ln -vs "$cloud_directory" "$home_directory" &&
|
||||||
|
echo "Folder $home_directory is now syncronized with cloud." || exit 1
|
||||||
|
else
|
||||||
|
echo "Directory $home_directory skipped, because it doesn't exist here $cloud_directory." &&
|
||||||
|
echo "Please create $cloud_directory or syncronize the cloud folder!" && exit 1;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user