You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*Verify that the user variable on line 5 is correct. The script will use the default user ```pi```. If that is the case for you, you don't need to change anything. Just keep following the instructions.
37
+
*If you are running the script as a different user than ```pi```, which is the default, the script will ask you if you want to install it as that user instead
38
38
```
39
39
./btsync.sh
40
40
```
@@ -44,7 +44,7 @@ Please be mindful: by using other URLs/links I can not garantuee that the script
44
44
Only use links provided by the Sync Staff on the forums or from the official BitTorrent Inc. website.
45
45
46
46
BitTorrent Sync will use a default configuration. Please make sure that it will work in your environment.
47
-
[Here](http://help.getsync.com/customer/portal/articles/2018454-running-sync-in-configuration-mode) and [here](http://help.getsync.com/customer/en/portal/articles/1902098-sync-preferences-general-advanced-more-options) are help articles from the [Sync Help Center](http://help.getsync.com/) that will guide you through the configuration options.
47
+
[Here](http://help.getsync.com/hc/en-us/articles/204762689-Running-Sync-in-configuration-mode) and [here](http://help.getsync.com/hc/en-us/articles/207371636-Power-user-preferences) are help articles from the [Sync Help Center](http://help.getsync.com/) that will guide you through the configuration options.
48
48
49
49
After the script is done, you want to have it automatically start after you reboot your Raspberry Pi.
50
50
To do that enter the following:```sudo update-rc.d btsync defaults```
#Change the $user variable to the user you would like Sync to be installed to and later run as
4
-
#Default is pi
5
-
user="pi"
6
-
# Don't alter variables below since they are relevant for running the script properly
7
-
btsdir="/home/$user/.btsync"
8
3
red=`tput setaf 1`
9
4
green=`tput setaf 2`
10
5
yellow=`tput setaf 3`
11
6
reset=`tput sgr0`
12
7
stat_y=${yellow}\?${reset}
13
8
stat_x=${red}X${reset}
14
9
stat_ok=${green}OK${reset}
15
-
dllink="$1"
16
10
err_cmd=""
17
11
18
12
if [ "$(id -u)"=="0" ];then
19
-
echo"[$stat_x] This script cannot run as root"
13
+
echo"[$stat_x] Error: This script cannot run as root"
20
14
exit 1
21
15
fi
16
+
#
17
+
# Don't alter the variables below. If you don't want to install the script as pi the script will ask you if you want to install it as the currently logged in user.
18
+
# Default is pi
19
+
#
20
+
if [ "$(whoami)"!="pi" ];then
21
+
echo"[$stat_x] Non-Default user $(whoami) detected. Default user to install script as is pi"
22
+
read -r -p "[$stat_y] Do you want to install the script as the user $(whoami) [yes/no]: " response
# So right now all BitTorrent Sync binary files are expected to be a .tar.gz file. If they are not the following command and thus the script will fail and exit.
118
+
err_cmd=$(sudo tar -zxvf $btsdir/*.tar.gz -C /usr/bin/ btsync 2>&1>/dev/null)
114
119
if [ $?-ne 0 ];then
115
-
echo -ne "[$stat_x] Error: There was an error downloading the binary"
116
-
echo -ne '\n'
117
-
exit 1
118
-
fi
119
-
err_cmd=$(sudo tar -zxvf $btsdir/btsync_arm.tar.gz -C /usr/bin/ btsync 2>&1>/dev/null)
120
-
if [ $?-ne 0 ];then
121
-
echo"[$stat_x] Error: Could not extract btsync_arm.tar.gz"
120
+
echo"[$stat_x] Error: Could not extract binary archive"
122
121
echo"[$stat_x] $err_cmd"
123
122
exit 1
124
123
fi
125
124
echo"[$stat_ok] Extraced the binary to /usr/bin/btsync"
tar -czPf /home/$user/btsync_backup_$backup_date.tar.gz /etc/init.d/btsync /etc/btsync/config.json /usr/bin/btsync ${btsdir} --exclude="*.log" --exclude="*.journal" --exclude="sync.log.*.zip"&# Backup the files in the background.
166
+
tar -czPf /home/$user/btsync_backup_$backup_date.tar.gz /etc/init.d/btsync /etc/btsync/config.json /usr/bin/btsync $btsdir --exclude="*.journal" --exclude="*.journal.zip" --exclude="*.log" --exclude="sync.log.*.zip"&# Backup the files in the background.
182
167
else
183
168
# That actually doesn't work yet... still have to figure that one out
184
-
echo"[$stat_x] Error: Copying failed"
169
+
echo"[$stat_x] Error: Backup failed"
170
+
echo"[$stat_x] Error: $btsdir does not exist"
185
171
sleep 0.7
186
172
exit 1
187
173
fi
188
174
# The /proc directory exists while the command runs.
189
175
while [ -e /proc/$! ];do
190
-
echo -ne "[ooo] ${backup_reason}\r"&& sleep 0.2
191
-
echo -ne "[Ooo] ${backup_reason}\r"&& sleep 0.2
192
-
echo -ne "[oOo] ${backup_reason}\r"&& sleep 0.2
193
-
echo -ne "[ooO] ${backup_reason}\r"&& sleep 0.2
194
-
echo -ne "[ooo] ${backup_reason}\r"&& sleep 0.2
195
-
echo -ne "[ooO] ${backup_reason}\r"&& sleep 0.2
196
-
echo -ne "[oOo] ${backup_reason}\r"&& sleep 0.2
197
-
echo -ne "[Ooo] ${backup_reason}\r"&& sleep 0.2
198
-
echo -ne "[ooo] ${backup_reason}\r"
176
+
echo -ne "[ooo] $backup_reason\r"&& sleep 0.2
177
+
echo -ne "[Ooo] $backup_reason\r"&& sleep 0.2
178
+
echo -ne "[oOo] $backup_reason\r"&& sleep 0.2
179
+
echo -ne "[ooO] $backup_reason\r"&& sleep 0.2
180
+
echo -ne "[ooo] $backup_reason\r"&& sleep 0.2
181
+
echo -ne "[ooO] $backup_reason\r"&& sleep 0.2
182
+
echo -ne "[oOo] $backup_reason\r"&& sleep 0.2
183
+
echo -ne "[Ooo] $backup_reason\r"&& sleep 0.2
184
+
echo -ne "[ooo] $backup_reason\r"
199
185
done
200
186
echo -e "\e[0K\r[$stat_ok] BitTorrent Sync has been successfully backed up at /home/$user/btsync_backup_$backup_date.tar.gz"
201
187
}
202
188
203
189
functionremove {
204
190
echo"[$stat_x] Are you sure you want to remove your BitTorrent Sync installation?"
205
191
echo"[$stat_x] That includes the following files and folders:"
206
-
echo"[$stat_x] /home/${user}/.btsync/ and all it's files and subfolders"
192
+
echo"[$stat_x] /home/$user/.btsync/ and all it's files and subfolders"
207
193
echo"[$stat_x] /etc/init.d/btsync"
208
194
echo"[$stat_x] /etc/btsync/config.json"
209
195
echo"[$stat_x] /usr/bin/btsync"
210
196
echo"[$stat_x] Files and folders that are being synced are not affected by this"
# This function checks for the HTTP Status Code prior of trying to donwnload any file. If the code is not 200 it will quit and let the user know what code came back
0 commit comments