-
Notifications
You must be signed in to change notification settings - Fork 0
/
spread.sh
executable file
·37 lines (33 loc) · 874 Bytes
/
spread.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
echo Starting spreading configs...
PWD=`pwd`
MYHOME="/home/ahmed/"
while read TARGET; do
if [[ ${TARGET:0:1} == "~" ]]
then
SOURCE=`echo $TARGET | sed "s,~,$PWD,g"`
DESTINATION=`echo $TARGET | sed "s,~,$MYHOME,g"`
else
SOURCE="$PWD/root$TARGET"
DESTINATION="$TARGET"
fi
DESTINATION=`dirname $DESTINATION`
mkdir -p $DESTINATION
echo $TARGET
rsync -r $SOURCE $DESTINATION
done < ./list
while read TARGET; do
if [[ ${TARGET:0:1} == "~" ]]
then
SOURCE=`echo $TARGET | sed "s,~,$PWD/files,g"`
DESTINATION=`echo $TARGET | sed "s,~,$MYHOME,g"`
else
SOURCE="$PWD/files/root$TARGET"
DESTINATION="$TARGET"
fi
DESTINATION=`dirname $DESTINATION`
mkdir -p $DESTINATION
echo $TARGET
rsync -r $SOURCE $DESTINATION
done < ./list_files
echo Done.