-
Notifications
You must be signed in to change notification settings - Fork 0
/
init
executable file
·69 lines (51 loc) · 1.69 KB
/
init
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
. "$DIR/script/globals"
. "$DIR/script/functions"
# Don't start if the system does not satisfy the requires binaries.
check_binaries
function check_requirements {
print_separator
echo "Checking folder requirements...\r\n"
if [ ! -d "$SSH_KEY_DIR" ]; then
echo "Could not find: $SSH_KEY_DIR directory, creating..."
${MKDIR_BIN} ${SSH_KEY_DIR}
${CHMOD_BIN} -R 700 ${SSH_KEY_DIR}
fi
if [ ! -d "$SSH_FULL_KEY_DIR" ]; then
echo "Could not find: $SSH_FULL_KEY_DIR directory, creating..."
${MKDIR_BIN} ${SSH_FULL_KEY_DIR}
${CHMOD_BIN} -R 700 ${SSH_FULL_KEY_DIR}
fi
if [ ! -d "$GPG_HOME_DIR" ]; then
echo "Could not find: $GPG_HOME_DIR directory, creating..."
${MKDIR_BIN} ${GPG_HOME_DIR}
${CHMOD_BIN} -R 700 ${GPG_HOME_DIR}
fi
print_separator
generate_master_key
}
function generate_master_key {
set_gpg_home
#[[ $(${GPG_AGENT}) == *"no agent running"* ]] && echo "NOT RUNNING BRO!"
# Check for version and call generate command.
echo $GPG_VERSION
if [ $GPG_VERSION -ge 2 ]; then
${GPG_BIN} --full-gen-key
else
${GPG_BIN} --gen-key
fi
${TOUCH_BIN} ${GPG_HOME_DIR}/gpg.conf
${TOUCH_BIN} ${GPG_HOME_DIR}/gpg-agent.conf
${CHMOD_BIN} -R 700 ${GPG_HOME_DIR}/*
}
echo "Are you sure you want to initialize this drive?"
echo "Running init on a drive that was already initialized can cause a lockout of your encrypted files! (y/n)"
echo # Move to a new line
select yn in "Yes" "No"; do
case $yn in
Yes ) check_requirements; break;;
No ) exit;;
esac
done