-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathinstall_ezshare.sh
executable file
·82 lines (66 loc) · 1.97 KB
/
install_ezshare.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
#!/usr/bin/env bash
create_venv() {
local env_name=${1:-".venv"}
python3 -m venv $env_name
}
install_deps() {
local env_name=${1:-".venv"}
source $env_name/bin/activate
if [ -f "requirements.txt" ]; then
pip install -r ./requirements.txt
fi
if [ -f "setup.py" ]; then
pip install -e .
fi
}
check_venv() {
local env_name=${1:-".venv"}
if [ -d "$env_name" ]; then
true
else
false
fi
}
check_python() {
if command -v python3 > /dev/null 2>&1 ; then
true
else
false
fi
}
venv_name=$HOME/.venv/ezshare_resmed
if ! check_python ; then
echo "Python3 not installed, please install"
exit 1
fi
if ! check_venv $venv_name ; then
create_venv $venv_name
fi
install_deps $venv_name
mkdir -p $HOME/.local/bin
mkdir -p $HOME/.config/ezshare_resmed
cp ezshare_resmed $HOME/.local/bin
cp ezshare_resmed.py $HOME/.local/bin
if ! [ -f "$HOME/.config/ezshare_resmed/config.ini" ]; then
cp ezshare_resmed_default.ini $HOME/.config/ezshare_resmed/config.ini
fi
chmod +x $HOME/.local/bin/ezshare_resmed
chmod +x $HOME/.local/bin/ezshare_resmed.py
if ! [[ ":$PATH:" == *":$HOME/.local/bin:"* ]]; then
echo -e "\nezshare_resmed is installed to $HOME/.local/bin which is not in your PATH"
echo "Add \$HOME/.local/bin to your PATH before running ezshare_resmed"
shell=$(basename $SHELL)
if [[ $shell == "zsh" ]]; then
echo "Your shell appears to be zsh. To set the PATH in zsh run:"
echo -e "\necho 'export PATH="\$HOME/.local/bin:\$PATH"' >> ~/.zshrc"
echo "source ~/.zshrc"
elif [[ $shell == "bash" ]]; then
echo "Your shell appears to be bash. To set the PATH in bash run:"
echo -e "\necho 'export PATH="\$HOME/.local/bin:\$PATH"' >> ~/.bashrc"
echo "source ~/.bashrc"
fi
fi
echo -e "\nInstallation complete"
echo "Default configuration file is $HOME/.config/ezshare_resmed/config.ini"
echo "Run with:"
echo -e "\nezshare_resmed"