New setup ; updater ; more options
This commit is contained in:
parent
8c65014654
commit
82f1b3a5b5
10
README.md
10
README.md
|
@ -10,13 +10,13 @@ server "upload" folder with your friends.
|
|||
|
||||
# dependencies
|
||||
- bash
|
||||
- curl (to check available version)
|
||||
- rsync
|
||||
- sshfs
|
||||
|
||||
# How to install ?
|
||||
You can manually copy, folders and files from this repo, or use setup.sh
|
||||
|
||||
|
||||
```
|
||||
git clone https://git.a-lec.org/echolib/filebox
|
||||
cd filebox
|
||||
|
@ -108,7 +108,7 @@ is set.
|
|||
Do not forget to unmount your mounted points using:
|
||||
|
||||
```
|
||||
filebox -U [OPT] (server name)
|
||||
filebox -u [OPT] (server name)
|
||||
```
|
||||
|
||||
# Help
|
||||
|
@ -136,7 +136,7 @@ $ filebox [ARGS]
|
|||
[OPT]
|
||||
-k : Copy, not move
|
||||
|
||||
unmount | -U [OPT] [NAME]
|
||||
unmount | -u [OPT] [NAME]
|
||||
: Unmount directories
|
||||
[OPT]
|
||||
dl : Download directory only
|
||||
|
@ -145,6 +145,10 @@ $ filebox [ARGS]
|
|||
get | -g [NAME]
|
||||
: List and choose files to download from server
|
||||
|
||||
-v : Show Installed version
|
||||
-vv : Show Installed and Available versions
|
||||
-U : Check and Update filebox
|
||||
|
||||
# Items Selector
|
||||
: L > Load again the list
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ fb_keep_bsize=10737418240
|
|||
# Reserved free space: 5Go (server)
|
||||
fb_keep_sbsize=5368709120
|
||||
|
||||
|
||||
app_name="filebox"
|
||||
# -------
|
||||
# Folders
|
||||
# -------
|
||||
|
@ -34,3 +36,7 @@ fb_file_conf_loc="$fb_dir_conf_user/filebox_loc.conf"
|
|||
fb_file_list="$fb_dir_conf_user/filelist"
|
||||
# Profile file
|
||||
fb_file_profile_list="$fb_dir_conf_user/profile"
|
||||
|
||||
# repo
|
||||
repo="https://git.a-lec.org/echolib/filebox/-/raw/main/usr/local/bin/filebox"
|
||||
repo_tar="https://git.a-lec.org/echolib/filebox/-/archive/main/filebox-main.tar.gz"
|
||||
|
|
141
setup.sh
141
setup.sh
|
@ -1,5 +1,4 @@
|
|||
#!/bin/bash
|
||||
# version: 0.1
|
||||
# file: setup.sh
|
||||
# Folder: filebox (from git clone)
|
||||
# git clone https://git.a-lec.org/echolib/filebox.git
|
||||
|
@ -12,23 +11,41 @@ unset ${!setup_@}
|
|||
#----------------------------------------------------------------------
|
||||
# Directories to CHOWN -R
|
||||
set_dir_R_CHO=(
|
||||
/var/lib/filebox
|
||||
/etc/filebox
|
||||
var/lib/filebox
|
||||
etc/filbox
|
||||
)
|
||||
|
||||
# bin Directories: Check ONLY with mkdir -p
|
||||
setup_dir_bin="/usr/local/bin"
|
||||
# Directories to check ONLY with mkdir -p
|
||||
setup_dir_bin="usr/local/bin"
|
||||
|
||||
# filename application to CHOWN
|
||||
setup_file_bin="filebox"
|
||||
# main app name
|
||||
setup_app_name="filebox"
|
||||
# filename application to CHOWN + CHMOD 755
|
||||
set_files_R_CHO=(
|
||||
upd
|
||||
)
|
||||
|
||||
# bin uri
|
||||
set_bin_uri="$setup_dir_bin/$setup_file_bin"
|
||||
|
||||
#======================================================================
|
||||
|
||||
#----------------------
|
||||
# Check commands exists
|
||||
#----------------------
|
||||
if__command() {
|
||||
! [[ `command -v $1` ]] \
|
||||
&& echo -e "! Missing $1 command" \
|
||||
&& exit 1
|
||||
}
|
||||
|
||||
if__command sudo
|
||||
if__command rsync
|
||||
|
||||
#------------------------
|
||||
# Check commands function
|
||||
#------------------------
|
||||
filebox__check_err() {
|
||||
setup__check_err() {
|
||||
if (( cmd_res == 0 ));then
|
||||
echo -ne " OK\n"
|
||||
else
|
||||
|
@ -42,17 +59,17 @@ fi
|
|||
#----------------------------------------------------------------------
|
||||
case "$1" in
|
||||
remove|-R)
|
||||
[[ -f "$set_bin_uri" ]] \
|
||||
&& echo "- Removing $set_bin_uri" \
|
||||
&& sudo rm -f "$set_bin_uri"
|
||||
[[ -f "/$set_bin_uri" ]] \
|
||||
&& echo "- Removing /$set_bin_uri" \
|
||||
&& sudo rm -f "/$set_bin_uri"
|
||||
|
||||
for setup_folder in ${set_dir_R_CHO[@]}
|
||||
do
|
||||
[[ -d "$setup_folder" ]] \
|
||||
&& echo "- Removing $setup_folder" \
|
||||
&& sudo rm -rf "$setup_folder"
|
||||
[[ -d "/$setup_folder" ]] \
|
||||
&& echo "- Removing /$setup_folder" \
|
||||
&& sudo rm -rf "/$setup_folder"
|
||||
done
|
||||
echo "# filebox is uninstalled. Thank you for testing."
|
||||
echo "# upd is uninstalled. Thank you for testing."
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -60,38 +77,54 @@ esac
|
|||
# Installation Process
|
||||
#----------------------------------------------------------------------
|
||||
setup__install() {
|
||||
|
||||
setup__gen_process() {
|
||||
echo "- Folder: /$1"
|
||||
|
||||
echo -ne " Created:"
|
||||
sudo mkdir -p "/$1" \
|
||||
&& cmd_res="$?" \
|
||||
&& setup__check_err
|
||||
|
||||
case "$2" in
|
||||
chdir)
|
||||
echo -ne " Owner $setup_user:"
|
||||
sudo chown -R "$setup_user":"$setup_user" "/$1" \
|
||||
&& cmd_res="$?" \
|
||||
&& setup__check_err
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -ne " Copy files:"
|
||||
sudo rsync -a "$1/" "/$1/" \
|
||||
&& cmd_res="$?" \
|
||||
&& setup__check_err
|
||||
}
|
||||
|
||||
for setup_folder in ${set_dir_R_CHO[@]}
|
||||
do
|
||||
echo "- Folder: $setup_folder"
|
||||
echo -ne " Created:"
|
||||
sudo mkdir -p "$setup_folder" \
|
||||
&& cmd_res="$?" \
|
||||
&& filebox__check_err
|
||||
echo -ne " Owner $setup_user:"
|
||||
sudo chown -R "$setup_user":"$setup_user" "$setup_folder" \
|
||||
&& cmd_res="$?" \
|
||||
&& filebox__check_err
|
||||
setup__gen_process "$setup_folder" chdir
|
||||
done
|
||||
echo "- Folder: $setup_dir_bin"
|
||||
echo -ne " Created:"
|
||||
sudo mkdir -p "$setup_dir_bin" \
|
||||
&& cmd_res="$?" \
|
||||
&& filebox__check_err
|
||||
echo "- File: $setup_file_bin"
|
||||
echo -ne " Copy:"
|
||||
sudo cp "$PWD$set_bin_uri" \
|
||||
"$set_bin_uri" \
|
||||
&& cmd_res="$?" \
|
||||
&& filebox__check_err
|
||||
echo -ne " Owner $setup_user:"
|
||||
sudo chown "$setup_user":"$setup_user" "$set_bin_uri" \
|
||||
&& cmd_res="$?" \
|
||||
&& filebox__check_err
|
||||
sudo chmod 755 "$set_bin_uri"
|
||||
|
||||
echo -e "\n# Thank you for installing filebox. Have fun !"
|
||||
setup__gen_process "$setup_dir_bin"
|
||||
for setup_file in ${set_files_R_CHO[@]}
|
||||
do
|
||||
echo -ne " Owner $setup_user for $setup_file:"
|
||||
sudo chown "$setup_user":"$setup_user" "/$setup_dir_bin/$setup_file" \
|
||||
&& cmd_res="$?" \
|
||||
&& setup__check_err
|
||||
sudo chmod 755 "/$setup_dir_bin/$setup_file"
|
||||
done
|
||||
|
||||
printf '\n%b\n%b\n%b\n' \
|
||||
"# Thank you for installing upd." \
|
||||
" (You can remove the repo and use upd -U to update)" \
|
||||
" Have fun !"
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# MAIN PROCESS
|
||||
#----------------------------------------------------------------------
|
||||
# PWD is Not a repo
|
||||
! [[ -d ".git" ]] \
|
||||
&& echo "! No repository here" \
|
||||
|
@ -99,24 +132,26 @@ echo -e "\n# Thank you for installing filebox. Have fun !"
|
|||
&& exit 0
|
||||
|
||||
# Updaate && Check Version
|
||||
git pull
|
||||
setup_ins_version=`
|
||||
awk 'NR==2 {print $3}' "$setup_dir_bin/$setup_file_bin" 2>/dev/null`
|
||||
awk 'NR==2 {print $3}' "/$setup_dir_bin/$setup_file_bin" 2>/dev/null`
|
||||
setup_new_version=`
|
||||
awk 'NR==2 {print $3}' "$PWD$setup_dir_bin/$setup_file_bin"`
|
||||
awk 'NR==2 {print $3}' "$setup_dir_bin/$setup_file_bin" 2>/dev/null`
|
||||
|
||||
[[ "$setup_ins_version" == "$setup_ins_version" ]] \
|
||||
[[ "$setup_ins_version" == "$setup_new_version" ]] \
|
||||
&& echo "$setup_file_bin is already up to date" \
|
||||
&& unset ${!setup_@} \
|
||||
&& exit 0
|
||||
|
||||
# Directory project name (First folder from git clone)
|
||||
setup_folder_git_name=`basename ${PWD}`
|
||||
read -rp ": Set $setup_folder_git_name for user ($USER)? " setup_user
|
||||
read -rp ": Set $setup_app_name for user $USER (Y|n|[set])? " setup_user
|
||||
case "$setup_user" in
|
||||
""|Y|y|O|o)
|
||||
setup_user="$USER"
|
||||
;;
|
||||
N|n)
|
||||
unset ${!setup_@}
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
! [[ `awk -F: '{print $1}' /etc/passwd | grep "$setup_user"` ]] \
|
||||
&& echo "! No registred user: $setup_user" \
|
||||
|
@ -125,18 +160,8 @@ case "$setup_user" in
|
|||
;;
|
||||
esac
|
||||
|
||||
echo -e "\n# Installation Schema:"
|
||||
for setup_folder in ${set_dir_R_CHO[@]}
|
||||
do
|
||||
printf '%s%s\n' \
|
||||
"- Folder: $setup_folder " \
|
||||
"; sudo mkdir -p + sudo chown -R $setup_user:$setup_user"
|
||||
done
|
||||
echo "- Folder: $setup_dir_bin ; sudo mkdir -p"
|
||||
echo "- File: $set_bin_uri ; sudo cp + sudo chown $setup_user:$setup_user"
|
||||
|
||||
echo
|
||||
echo "# Version: $setup_ins_version > $setup_new_version"
|
||||
echo "# $setup_app_name Version: $setup_ins_version > $setup_new_version"
|
||||
read -rp "# Ready to install (y|N)? " setup_confirm
|
||||
case "$setup_confirm" in
|
||||
Y|y|O|o) setup__install ;;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# version: 0.1.3
|
||||
# version: 0.1.4
|
||||
# file: filebox
|
||||
# Folder: /usr/local/bin
|
||||
# By echolib
|
||||
|
@ -108,7 +108,7 @@ case "$1" in
|
|||
send__files
|
||||
;;
|
||||
|
||||
unmount|-U)
|
||||
unmount|-u)
|
||||
if__file "$fb_dir_scripts/mount__srv" source
|
||||
case "$2" in
|
||||
ul)
|
||||
|
@ -147,6 +147,27 @@ case "$1" in
|
|||
get__files
|
||||
;;
|
||||
|
||||
-U)
|
||||
if__file "$fb_dir_scripts/updater" source
|
||||
Updater
|
||||
;;
|
||||
|
||||
version|-v)
|
||||
awk 'NR==2 {print "# Installed:",$3}' "/usr/local/bin/filebox"
|
||||
;;
|
||||
|
||||
-vv)
|
||||
v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"`
|
||||
echo -n "# $app_name Current: $v_cur | "
|
||||
if__command curl
|
||||
v_onl=`curl -s "$repo" | awk 'NR==2 {print $3}'`
|
||||
echo -ne "Online: $v_onl\n"
|
||||
;;
|
||||
|
||||
--readme)
|
||||
if__file "/var/lib/filebox/README.md" read
|
||||
;;
|
||||
|
||||
--help|-h|help|*)
|
||||
if__file "$fb_dir_scripts/help" read
|
||||
;;
|
||||
|
|
|
@ -10,13 +10,13 @@ server "upload" folder with your friends.
|
|||
|
||||
# dependencies
|
||||
- bash
|
||||
- curl (to check available version)
|
||||
- rsync
|
||||
- sshfs
|
||||
|
||||
# How to install ?
|
||||
You can manually copy, folders and files from this repo, or use setup.sh
|
||||
|
||||
|
||||
```
|
||||
git clone https://git.a-lec.org/echolib/filebox
|
||||
cd filebox
|
||||
|
@ -108,7 +108,7 @@ is set.
|
|||
Do not forget to unmount your mounted points using:
|
||||
|
||||
```
|
||||
filebox -U [OPT] (server name)
|
||||
filebox -u [OPT] (server name)
|
||||
```
|
||||
|
||||
# Help
|
||||
|
@ -136,7 +136,7 @@ $ filebox [ARGS]
|
|||
[OPT]
|
||||
-k : Copy, not move
|
||||
|
||||
unmount | -U [OPT] [NAME]
|
||||
unmount | -u [OPT] [NAME]
|
||||
: Unmount directories
|
||||
[OPT]
|
||||
dl : Download directory only
|
||||
|
@ -145,6 +145,10 @@ $ filebox [ARGS]
|
|||
get | -g [NAME]
|
||||
: List and choose files to download from server
|
||||
|
||||
-v : Show Installed version
|
||||
-vv : Show Installed and Available versions
|
||||
-U : Check and Update filebox
|
||||
|
||||
# Items Selector
|
||||
: L > Load again the list
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ $ filebox [ARGS]
|
|||
: No [NAME], use (default)
|
||||
|
||||
[ARGS]:
|
||||
help
|
||||
: This Help
|
||||
help : This Help
|
||||
--readme : Show readme
|
||||
|
||||
config | -C [OPT] [NAME]
|
||||
: Configure access to a server [NAME]
|
||||
|
@ -20,7 +20,7 @@ $ filebox [ARGS]
|
|||
[OPT]
|
||||
-k : Copy, not move
|
||||
|
||||
unmount | -U [OPT] [NAME]
|
||||
unmount | -u [OPT] [NAME]
|
||||
: Unmount directories
|
||||
[OPT]
|
||||
dl : Download directory only
|
||||
|
@ -29,6 +29,10 @@ $ filebox [ARGS]
|
|||
get | -g [NAME]
|
||||
: List and choose files to download from server
|
||||
|
||||
-v : Show Installed version
|
||||
-vv : Show Installed and Available versions
|
||||
-U : Check and Update filebox
|
||||
|
||||
# Items Selector
|
||||
: L > Load again the list
|
||||
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
# file: updater
|
||||
# Folder: /var/lib/upd/scripts/
|
||||
# By echolib
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#======================================================================
|
||||
# Automatic Updater
|
||||
#======================================================================
|
||||
Updater() {
|
||||
if__command curl
|
||||
if__command rsync
|
||||
|
||||
v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"`
|
||||
echo -n "# $app_name Current: $v_cur | "
|
||||
v_onl=`curl -s "$repo" | awk 'NR==2 {print $3}'`
|
||||
if ! [[ $v_onl ]];then
|
||||
echo -ne "Online: Unknown\n"
|
||||
exit 1
|
||||
else
|
||||
echo -ne "Online: $v_onl\n"
|
||||
fi
|
||||
|
||||
printf -v versions '%s\n%s' "$v_cur" "$v_onl"
|
||||
|
||||
[[ `sort -V <<< "$versions" | tail -1` == $v_cur ]] \
|
||||
&& return
|
||||
|
||||
# Get archive
|
||||
cd /tmp
|
||||
curl -L -o ${app_name}-main.tar.gz "$repo_tar" 2>/dev/null
|
||||
! [[ -f "${app_name}-main.tar.gz" ]] \
|
||||
&& echo "! Download error" \
|
||||
&& return
|
||||
|
||||
tar -xzf ${app_name}-main.tar.gz
|
||||
cd ${app_name}-main
|
||||
rsync -a --delete "usr/local/bin/" "/usr/local/bin"
|
||||
rsync -a --delete "var/lib/${app_name}/" "/var/lib/${app_name}/"
|
||||
rsync -a --delete "etc/${app_name}/" "/etc/${app_name}/"
|
||||
|
||||
# Check
|
||||
v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"`
|
||||
echo "# $app_name updated to: $v_cur"
|
||||
|
||||
rm -rf /tmp/${app_name}-main
|
||||
rm -f ${app_name}-main.tar.gz
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
#!/bin/bash
|
||||
# version: 0.1
|
||||
# file: setup.sh
|
||||
# Folder: filebox (from git clone)
|
||||
# git clone https://git.a-lec.org/echolib/filebox.git
|
||||
|
@ -12,23 +11,41 @@ unset ${!setup_@}
|
|||
#----------------------------------------------------------------------
|
||||
# Directories to CHOWN -R
|
||||
set_dir_R_CHO=(
|
||||
/var/lib/filebox
|
||||
/etc/filebox
|
||||
var/lib/filebox
|
||||
etc/filbox
|
||||
)
|
||||
|
||||
# bin Directories: Check ONLY with mkdir -p
|
||||
setup_dir_bin="/usr/local/bin"
|
||||
# Directories to check ONLY with mkdir -p
|
||||
setup_dir_bin="usr/local/bin"
|
||||
|
||||
# filename application to CHOWN
|
||||
setup_file_bin="filebox"
|
||||
# main app name
|
||||
setup_app_name="filebox"
|
||||
# filename application to CHOWN + CHMOD 755
|
||||
set_files_R_CHO=(
|
||||
upd
|
||||
)
|
||||
|
||||
# bin uri
|
||||
set_bin_uri="$setup_dir_bin/$setup_file_bin"
|
||||
|
||||
#======================================================================
|
||||
|
||||
#----------------------
|
||||
# Check commands exists
|
||||
#----------------------
|
||||
if__command() {
|
||||
! [[ `command -v $1` ]] \
|
||||
&& echo -e "! Missing $1 command" \
|
||||
&& exit 1
|
||||
}
|
||||
|
||||
if__command sudo
|
||||
if__command rsync
|
||||
|
||||
#------------------------
|
||||
# Check commands function
|
||||
#------------------------
|
||||
filebox__check_err() {
|
||||
setup__check_err() {
|
||||
if (( cmd_res == 0 ));then
|
||||
echo -ne " OK\n"
|
||||
else
|
||||
|
@ -42,17 +59,17 @@ fi
|
|||
#----------------------------------------------------------------------
|
||||
case "$1" in
|
||||
remove|-R)
|
||||
[[ -f "$set_bin_uri" ]] \
|
||||
&& echo "- Removing $set_bin_uri" \
|
||||
&& sudo rm -f "$set_bin_uri"
|
||||
[[ -f "/$set_bin_uri" ]] \
|
||||
&& echo "- Removing /$set_bin_uri" \
|
||||
&& sudo rm -f "/$set_bin_uri"
|
||||
|
||||
for setup_folder in ${set_dir_R_CHO[@]}
|
||||
do
|
||||
[[ -d "$setup_folder" ]] \
|
||||
&& echo "- Removing $setup_folder" \
|
||||
&& sudo rm -rf "$setup_folder"
|
||||
[[ -d "/$setup_folder" ]] \
|
||||
&& echo "- Removing /$setup_folder" \
|
||||
&& sudo rm -rf "/$setup_folder"
|
||||
done
|
||||
echo "# filebox is uninstalled. Thank you for testing."
|
||||
echo "# upd is uninstalled. Thank you for testing."
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -60,38 +77,54 @@ esac
|
|||
# Installation Process
|
||||
#----------------------------------------------------------------------
|
||||
setup__install() {
|
||||
|
||||
setup__gen_process() {
|
||||
echo "- Folder: /$1"
|
||||
|
||||
echo -ne " Created:"
|
||||
sudo mkdir -p "/$1" \
|
||||
&& cmd_res="$?" \
|
||||
&& setup__check_err
|
||||
|
||||
case "$2" in
|
||||
chdir)
|
||||
echo -ne " Owner $setup_user:"
|
||||
sudo chown -R "$setup_user":"$setup_user" "/$1" \
|
||||
&& cmd_res="$?" \
|
||||
&& setup__check_err
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -ne " Copy files:"
|
||||
sudo rsync -a "$1/" "/$1/" \
|
||||
&& cmd_res="$?" \
|
||||
&& setup__check_err
|
||||
}
|
||||
|
||||
for setup_folder in ${set_dir_R_CHO[@]}
|
||||
do
|
||||
echo "- Folder: $setup_folder"
|
||||
echo -ne " Created:"
|
||||
sudo mkdir -p "$setup_folder" \
|
||||
&& cmd_res="$?" \
|
||||
&& filebox__check_err
|
||||
echo -ne " Owner $setup_user:"
|
||||
sudo chown -R "$setup_user":"$setup_user" "$setup_folder" \
|
||||
&& cmd_res="$?" \
|
||||
&& filebox__check_err
|
||||
setup__gen_process "$setup_folder" chdir
|
||||
done
|
||||
echo "- Folder: $setup_dir_bin"
|
||||
echo -ne " Created:"
|
||||
sudo mkdir -p "$setup_dir_bin" \
|
||||
&& cmd_res="$?" \
|
||||
&& filebox__check_err
|
||||
echo "- File: $setup_file_bin"
|
||||
echo -ne " Copy:"
|
||||
sudo cp "$PWD$set_bin_uri" \
|
||||
"$set_bin_uri" \
|
||||
&& cmd_res="$?" \
|
||||
&& filebox__check_err
|
||||
echo -ne " Owner $setup_user:"
|
||||
sudo chown "$setup_user":"$setup_user" "$set_bin_uri" \
|
||||
&& cmd_res="$?" \
|
||||
&& filebox__check_err
|
||||
sudo chmod 755 "$set_bin_uri"
|
||||
|
||||
echo -e "\n# Thank you for installing filebox. Have fun !"
|
||||
setup__gen_process "$setup_dir_bin"
|
||||
for setup_file in ${set_files_R_CHO[@]}
|
||||
do
|
||||
echo -ne " Owner $setup_user for $setup_file:"
|
||||
sudo chown "$setup_user":"$setup_user" "/$setup_dir_bin/$setup_file" \
|
||||
&& cmd_res="$?" \
|
||||
&& setup__check_err
|
||||
sudo chmod 755 "/$setup_dir_bin/$setup_file"
|
||||
done
|
||||
|
||||
printf '\n%b\n%b\n%b\n' \
|
||||
"# Thank you for installing upd." \
|
||||
" (You can remove the repo and use upd -U to update)" \
|
||||
" Have fun !"
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# MAIN PROCESS
|
||||
#----------------------------------------------------------------------
|
||||
# PWD is Not a repo
|
||||
! [[ -d ".git" ]] \
|
||||
&& echo "! No repository here" \
|
||||
|
@ -99,24 +132,26 @@ echo -e "\n# Thank you for installing filebox. Have fun !"
|
|||
&& exit 0
|
||||
|
||||
# Updaate && Check Version
|
||||
git pull
|
||||
setup_ins_version=`
|
||||
awk 'NR==2 {print $3}' "$setup_dir_bin/$setup_file_bin" 2>/dev/null`
|
||||
awk 'NR==2 {print $3}' "/$setup_dir_bin/$setup_file_bin" 2>/dev/null`
|
||||
setup_new_version=`
|
||||
awk 'NR==2 {print $3}' "$PWD$setup_dir_bin/$setup_file_bin"`
|
||||
awk 'NR==2 {print $3}' "$setup_dir_bin/$setup_file_bin" 2>/dev/null`
|
||||
|
||||
[[ "$setup_ins_version" == "$setup_ins_version" ]] \
|
||||
[[ "$setup_ins_version" == "$setup_new_version" ]] \
|
||||
&& echo "$setup_file_bin is already up to date" \
|
||||
&& unset ${!setup_@} \
|
||||
&& exit 0
|
||||
|
||||
# Directory project name (First folder from git clone)
|
||||
setup_folder_git_name=`basename ${PWD}`
|
||||
read -rp ": Set $setup_folder_git_name for user ($USER)? " setup_user
|
||||
read -rp ": Set $setup_app_name for user $USER (Y|n|[set])? " setup_user
|
||||
case "$setup_user" in
|
||||
""|Y|y|O|o)
|
||||
setup_user="$USER"
|
||||
;;
|
||||
N|n)
|
||||
unset ${!setup_@}
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
! [[ `awk -F: '{print $1}' /etc/passwd | grep "$setup_user"` ]] \
|
||||
&& echo "! No registred user: $setup_user" \
|
||||
|
@ -125,18 +160,8 @@ case "$setup_user" in
|
|||
;;
|
||||
esac
|
||||
|
||||
echo -e "\n# Installation Schema:"
|
||||
for setup_folder in ${set_dir_R_CHO[@]}
|
||||
do
|
||||
printf '%s%s\n' \
|
||||
"- Folder: $setup_folder " \
|
||||
"; sudo mkdir -p + sudo chown -R $setup_user:$setup_user"
|
||||
done
|
||||
echo "- Folder: $setup_dir_bin ; sudo mkdir -p"
|
||||
echo "- File: $set_bin_uri ; sudo cp + sudo chown $setup_user:$setup_user"
|
||||
|
||||
echo
|
||||
echo "# Version: $setup_ins_version > $setup_new_version"
|
||||
echo "# $setup_app_name Version: $setup_ins_version > $setup_new_version"
|
||||
read -rp "# Ready to install (y|N)? " setup_confirm
|
||||
case "$setup_confirm" in
|
||||
Y|y|O|o) setup__install ;;
|
||||
|
|
Loading…
Reference in New Issue