public
Description: Simple backup shell scripts
Homepage:
Clone URL: git://github.com/raphinou/shbackup.git
shbackup / encrypt_files.sh
100755 31 lines (25 sloc) 0.869 kb
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
#!/bin/bash
# encrypts files with openssl, with the password put in file named pass
# without args: encrypts all files in $backup_base
# 1 arg: directory: encrypts all files in that directory
# 1 arg: file: encrypts that file
# Note the source files are deleted
 
. ./backup_vars.sh
 
if [[ $# == 0 ]]; then
arg=$backup_base
else
arg=$1
fi
 
if [[ -d $arg ]]; then
echo "encrypting all files in dir $arg"
        for f in $arg/*; do
                [[ ! -f $f ]] && continue
echo "encrypting $f"
                openssl des3 -e -in $f -out $f.enc -a -salt -kfile $scripts_dir/pass
if [ $? == 0 ]; then rm $f; fi
done
elif [[ -f $arg ]]; then
echo "encrypting file $arg"
        [[ -f $arg ]] && openssl des3 -e -in $arg -out $arg.enc -a -salt -kfile $scripts_dir/pass
        if [ $? == 0 ]; then rm $arg; fi
 
fi