Skip to content
Snippets Groups Projects
Commit feaf22f5 authored by efer's avatar efer
Browse files

source profile + check for binaries before rcloneconf use

parent e5c63094
No related branches found
No related tags found
No related merge requests found
......@@ -209,10 +209,13 @@ $(echo $PATH | grep -o $BIN_DIR &>/dev/null)
if [ $? -ne 0 ]; then
if [ $SHELL == '/bin/bash' ]; then
echo -e "\nexport PATH=$PATH:$BIN_DIR" >> $H/.bash_profile
source $H/.bash_profile
elif [ $SHELL == '/bin/zsh' ]; then
echo -e "\nexport PATH=$PATH:$BIN_DIR" >> $H/.zprofile
source $H/.zprofile
else
echo -e "\nexport PATH=$PATH:$BIN_DIR" >> $H/.profile
source $H/.profile
fi
fi
......@@ -332,10 +335,13 @@ echo -e "[cleanup]" $G_"OK"$_N
#
# Rclone config
#
RCLONEBIN=$(which rclone)
AGEBIN=$(which age)
if [ $RCLONEBIN ] && [ $AGEBIN ]; then
echo -e "\nWriting rclone files..."
RCLONE_DIR="$H/.config/rclone"
pwg() {
head /dev/urandom | LC_ALL=C tr -dc A-Za-z0-9+=/ | head -c 16 | rclone obscure -
head /dev/urandom | LC_ALL=C tr -dc A-Za-z0-9+=/ | head -c 16 | $RCLONEBIN obscure -
}
rcloneconf() {
P1=$(pwg)
......@@ -356,7 +362,7 @@ password2 = $P2
EOF
# Only encrypt comp-backup remotes
age -o $FILE_DIR/rclone.conf.age -r $ITSAGEPUBLICKEY $FILE_DIR/rclone.conf
$AGEBIN -o $FILE_DIR/rclone.conf.age -r $ITSAGEPUBLICKEY $FILE_DIR/rclone.conf
scp -i $SSHKEY $FILE_DIR/rclone.conf.age $RUSER@$TARGETNODE:$RHOME/$SCRIPTNAME/$HOST/ &>/dev/null
rm -f $FILE_DIR/rclone.conf
}
......@@ -374,6 +380,9 @@ else
rcloneconf
fi
echo -e "[rclone config]" $G_"OK"$_N
else
echo -e "[rclone config]" $R_"Problem finding rclone/age"$_N
fi
#
# Prepare Rclone filter
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment