-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·41 lines (32 loc) · 1.16 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·41 lines (32 loc) · 1.16 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
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
#----------------------------------------[ VARS ]
path="/usr/bin/"
file="fssh.sh"
autocomplete_path="/etc/bash_completion.d/"
autocomplete_file="fssh-autocomplete"
#--------------------------------[ VALIDANTIONS ]
# Check root permission
if [[ $(id -u) != 0 ]] ; then
echo -e "Must run as root or using sudo"
exit
fi
# Check file existence
if [[ ! -f ${file} ]] ; then
echo -e "Script [ ${file} ] not find in actual directory"
exit
fi
#----------------------------------------[ Main ]
echo -e "Setting execution permission"
chmod +x ${file}
echo -e "Installing in system"
mv ${file} ${path}${file} || { echo "Fail to install in ${path}"; exit; }
ln -s ${path}${file} ${path}fssh || { echo "Fail to create symbolic link"; exit; }
echo -e "Setting autocomplete"
if [[ ! -d ${autocomplete_path} ]] ; then
echo "Creating directory [ ${autocomplete_path} ]"
mkdir -p ${autocomplete_path} || { echo -e "\nError creating ${autocomplete_path}"; exit 1; }
fi
mv ${autocomplete_file} ${autocomplete_path}fssh
echo "source ${autocomplete_path}fssh" >> ${HOME}/.bashrc
source ${autocomplete_path}fssh
echo -e "Installation completed \nUse fssh to use the program"