2222
2323function stop_sync {
2424 echo " [$stat_y ] Trying to stop a running BitTorrent Sync instance"
25- sleep 0.6
25+ sleep 0.5
2626 syncpid=" $( ps aux | grep btsync | grep -v grep | grep -v /bin/bash | awk ' {print $2}' ) "
2727 if [ -z $syncpid ]; then
2828 echo " [$stat_ok ] There is no instance of BitTorrent Sync running "
29- sleep 0.6
29+ sleep 0.5
3030 else
3131 err_cmd=$( sudo pkill -15 -x btsync 2>&1 > /dev/null)
3232 if [ $? -ne 0 ]; then
3333 echo " [$stat_x ] Error: There was an error stopping the BitTorrent Sync instance"
3434 if [ ! $err_cmd == " " ]; then
3535 echo " [$stat_x ] $err_cmd "
3636 fi
37- sleep 0.6
37+ sleep 0.5
3838 exit 1
3939 else
4040 echo " [$stat_ok ] The running instance of BitTorrent Sync has been stopped (PID: $syncpid )"
41- sleep 0.6
41+ sleep 0.5
4242 fi
4343 fi
4444}
4545
4646function install_preperations {
4747 if [ ! -d " $btsdir " ]; then
4848 echo " [$stat_ok ] Trying to create installation folder $btsdir "
49- sleep 0.6
49+ sleep 0.5
5050 err_cmd=$( mkdir $btsdir 2>&1 > /dev/null)
5151 if [ $? -ne 0 ]; then
5252 echo " [$stat_x ] Could not create installation folder $btsdir "
5353 echo " [$stat_x ] $err_cmd "
5454 exit 1
5555 fi
5656 echo " [$stat_ok ] BitTorrent Sync installation folder has been created ($btsdir )"
57- sleep 0.6
57+ sleep 0.5
5858 else
5959 echo " [$stat_x ] BitTorrent Sync installation folder $btsdir already exists"
60- sleep 0.6
60+ sleep 0.5
6161 read -r -p " [$stat_x ] Delete all files and sub-folders inside $btsdir ? [Y/N]: " response
6262 if [[ $response =~ ^([yY][eE][sS]| [yY])$ ]]; then
6363 echo -ne " [$stat_y ] Deleting all files in $btsdir \r"
@@ -71,48 +71,48 @@ function install_preperations {
7171 fi
7272 if [ -f $btsdir /btsync_arm.tar.gz ]; then
7373 echo " [$stat_y ] A binary file already exists"
74- sleep 0.6
74+ sleep 0.5
7575 echo " [$stat_ok ] Trying to remove and re-download the latest binary"
7676 err_cmd=$( rm $btsdir /btsync_arm.tar.gz 2>&1 > /dev/null)
7777 if [ $? -ne 0 ]; then
7878 echo " [$stat_x ] Error: Could not remove $btsdir /btsync_arm.tar.gz"
7979 echo " [$stat_x ] $err_cmd "
80- sleep 0.6
80+ sleep 0.5
8181 exit 1
8282 fi
8383 fi
8484 fi
8585}
8686
8787function install {
88- sleep 0.6
88+ sleep 0.5
8989 err_cmd=$( cd $btsdir 2>&1 > /dev/null)
9090 if [ $? -ne 0 ]; then
9191 echo " [$stat_x ] Error: Could not change to $btsdir since it does not exist"
9292 echo " [$stat_x ] $err_cmd "
9393 exit 1
9494 fi
9595 if [ -z $dllink ]; then
96- echo " [$stat_ok ] Downloading the latest stable version from BitTorrent Inc"
96+ echo " [$stat_y ] Downloading the latest stable version from BitTorrent Inc"
9797 curl -# -o $btsdir /btsync_arm.tar.gz https://download-cdn.getsync.com/stable/linux-arm/BitTorrent-Sync_arm.tar.gz
9898 if [ $? -ne 0 ]; then
9999 echo " [$stat_x ] Error: There was an error downloading the BiTorrent Sync binary"
100100 exit 1
101101 else
102- echo " [ $stat_ok ] Successfully downloaded the BiTorrent Sync binary"
102+ echo -en " \e[1A " ; echo -e " \e[0K\r[ $stat_ok ] Successfully downloaded the binary"
103103 fi
104104 else
105- echo " [$stat_ok ] Downloading the binary from the link provided"
105+ echo " [$stat_y ] Downloading the binary from the link provided"
106106 curl -# -o $btsdir /btsync_arm.tar.gz $dllink
107107 if [ $? -ne 0 ]; then
108108 echo " [$stat_x ] Error: There was an error downloading the file using the link you provided. Please check the URL and try again"
109109 exit 1
110110 else
111- echo " [ $stat_ok ] Successfully downloaded the BiTorrent Sync binary"
111+ echo -en " \e[1A " ; echo -e " \e[0K\r[ $stat_ok ] Successfully downloaded the binary"
112112 fi
113113 fi
114114 if [ $? -ne 0 ]; then
115- echo -ne " [$stat_x ] Error: There was an error downloading the BiTorrent Sync binary\r "
115+ echo -ne " [$stat_x ] Error: There was an error downloading the binary"
116116 echo -ne ' \n'
117117 exit 1
118118 fi
@@ -122,7 +122,7 @@ function install {
122122 echo " [$stat_x ] $err_cmd "
123123 exit 1
124124 fi
125- echo " [$stat_ok ] Extraced the BitTorrent Sync binary to /usr/bin/btsync"
125+ echo " [$stat_ok ] Extraced the binary to /usr/bin/btsync"
126126 err_cmd=$( rm $btsdir /btsync_arm.tar.gz 2>&1 > /dev/null)
127127 if [ $? -ne 0 ]; then
128128 echo " [$stat_x ] Error: Could not remove $btsdir /btsync_arm.tar.gz"
@@ -137,9 +137,9 @@ function btsync_initscript {
137137 else
138138 err_cmd=$( curl -o $btsdir /btsync_init https://raw.githubusercontent.com/moritzdietz/pi-syncscript/master/configuration-files/btsync 2>&1 > /dev/null)
139139 if [ $? -ne 0 ]; then
140- echo " [$stat_x ] Error: There was an error downloading the BitTorrent Sync init.d script"
140+ echo " [$stat_x ] Error: There was an error downloading the init.d script"
141141 echo " [$stat_x ] $err_cmd "
142- sleep 0.6
142+ sleep 0.5
143143 exit 1
144144 else
145145 sed -r -i.tmp " s/\bpi\b/$user /g" $btsdir /btsync_init
@@ -154,9 +154,9 @@ function btsyncconfig {
154154 if [ ! -f /etc/btsync/config.json ]; then
155155 err_cmd=$( curl -o $btsdir /config.json https://raw.githubusercontent.com/moritzdietz/pi-syncscript/master/configuration-files/config.json 2>&1 > /dev/null)
156156 if [ $? -ne 0 ]; then
157- echo " [$stat_x ] Error: There was an error downloading the BitTorrent Sync configuration file"
157+ echo " [$stat_x ] Error: There was an error downloading the configuration file"
158158 echo " [$stat_x ] $err_cmd "
159- sleep 0.6
159+ sleep 0.5
160160 exit 1
161161 else
162162 sed -r -i.tmp " s/\bpi\b/$user /g" $btsdir /config.json
@@ -173,7 +173,7 @@ function btsyncconfig {
173173
174174function backup {
175175 backup_date=$( date +" %d-%m-%Y_%H-%M-%S" )
176- backup_reason=" The BitTorrent Sync is being backed up as (/home/ $user /btsync_backup_ $backup_date .tar.gz) "
176+ backup_reason=" BitTorrent Sync is being backed up"
177177 # Look for the 4 common signals that indicate this script was killed.
178178 # If the background command was started, kill it, too.
179179 if [ -e ${btsdir} ]; then
@@ -197,7 +197,7 @@ function backup {
197197 echo -ne " [Ooo] ${backup_reason} \r" && sleep 0.2
198198 echo -ne " [ooo] ${backup_reason} \r"
199199 done
200- echo -e " \e[0K\r[$stat_ok ] BitTorrent Sync has been successfully backed up"
200+ echo -e " \e[0K\r[$stat_ok ] BitTorrent Sync has been successfully backed up at /home/ $user /btsync_backup_ $backup_date .tar.gz "
201201}
202202
203203function remove {
@@ -230,14 +230,20 @@ function remove {
230230 fi
231231}
232232
233+ function version_check {
234+ if [ -f /usr/bin/btsync ]; then
235+ echo $( /usr/bin/btsync -help | grep " BitTorrent Sync" | awk {' print $3" "$4' })
236+ fi
237+ }
238+
233239read -r -p " [$stat_y ] Choose one of the BitTorrent Sync Script options [(i)nstall(default)/(u)pdate/(b)ackup/(r)emove]: " response
234240if [[ $response =~ ^([u| U]| [u| U]pdate)$ ]]; then
235241 stop_sync
236- echo " [$stat_ok ] Updating BitTorrent Sync from version" $( /usr/bin/btsync -help | grep " BitTorrent Sync " | awk { ' print $3" "$4 ' } ) " to the latest available version"
242+ echo " [$stat_ok ] Updating BitTorrent Sync from version $( version_check ) to the latest available version"
237243 install $dllink
238244 btsync_initscript
239245 btsyncconfig
240- echo " [$stat_ok ] Updated BitTorrent Sync to version" $( /usr/bin/btsync -help | grep " BitTorrent Sync " | awk { ' print $3" "$4 ' } )
246+ echo " [$stat_ok ] Updated BitTorrent Sync to version $( version_check ) "
241247 echo " [$stat_ok ] You can now start BitTorrent Sync by typing \" sudo service btsync start\" "
242248 exit 0
243249elif [[ $response =~ ^([b| B]| [b| B]ackup)$ ]]; then
@@ -250,7 +256,7 @@ elif [[ $response =~ ^(""|[i|I]|[i|I]nstall)$ ]]; then
250256 install
251257 btsync_initscript
252258 btsyncconfig
253- echo " [$stat_ok ] Installed BitTorrent Sync version" $( /usr/bin/btsync -help | grep " BitTorrent Sync " | awk { ' print $3" "$4 ' } )
259+ echo " [$stat_ok ] Installed BitTorrent Sync version $( version_check ) "
254260 echo " [$stat_ok ] You can now start BitTorrent Sync by typing \" sudo service btsync start\" "
255261 exit 0
256262elif [[ $response =~ ^(" " | [r| R]| [r| R]emove)$ ]]; then
@@ -259,4 +265,4 @@ elif [[ $response =~ ^(""|[r|R]|[r|R]emove)$ ]]; then
259265else
260266 echo " [$stat_x ] You did not choose one of the provided script options. Please try again."
261267 exit 0
262- fi
268+ fi
0 commit comments