-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·83 lines (75 loc) · 2.43 KB
/
install.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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo -e "Checking whether python3 is present..."
if command -v python3 >/dev/null 2>&1
then
echo -e "\033[32mFound.\033[0m"
else
echo -e "\033[91mCould not find Python3.\033[0m"
fi
echo ''
echo -e "This script will install the requirements listed in "
echo -e "$DIR/requirements.txt"
echo -e "using python3 -m pip install -r .../requirements.txt"
echo -e "You can do this yourself manually later."
echo ''
read -p $'\033[33mInstall dependencies? [Y/n]?\033[0m ' -r
if [[ ! $REPLY =~ ^[Nn]$ ]]
then
python3 -m pip install -r "$DIR/requirements.txt"
if [ ! $? -eq 0 ]
then
echo -e "\033[91mSomething went wrong.\033[0m"
exit 1
fi
fi
if [ ! -f "$HOME/bin/fleet" ]
then
echo ''
echo -e "This script will add a symlink from"
echo -e "$HOME/bin/fleet"
echo -e "to"
echo -e "$DIR/fleet.py"
echo -e "so that you can call fleet from any directory."
read -p $'\033[33mIs this ok [N/y]?\033[0m ' -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
if [ ! -d $HOME/bin ]; then
echo ''
echo -e "$HOME/bin does not exist, creating that directory."
read -p '\033[33mIs this ok [N/y]?\033[0m ' -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
mkdir $HOME/bin
export PATH="$HOME/bin:$PATH"
echo -e "\033[32mCreated $HOME/bin\033[0m"
fi
if ln -s "$DIR/fleet.py" "$HOME/bin/fleet"
then
echo -e "\033[32mDone.\033[0m"
else
echo -e "\033[91mSomething went wrong.\033[0m"
fi
fi
if [ ! -f "$DIR/secrets.json" ]
then
echo ''
echo 'Some further setup is needed to allow fleet to connect to Flounder'
echo 'and upload your posts.'
echo '(Consider going through the source of install.sh at this point '
echo 'to make sure that I'"'"'m not stealing your credentials.)'
echo ''
echo -n '{ "flounder": { "user": "' > "$DIR/secrets.json"
read -p 'Flounder username: ' -r
echo -n "$REPLY" >> secrets.json
echo -n '", "password": "' >> secrets.json
read -p 'Flounder password: ' -r -s
echo -n "$REPLY" >> secrets.json
echo -n '" } }' >> secrets.json
echo -e "\033[32mDone.\033[0m"
echo "(If you wish to change the submitted data, you can edit $DIR/secrets.json directly.)"
fi