-
Notifications
You must be signed in to change notification settings - Fork 30
/
ya-setup
executable file
·81 lines (65 loc) · 2.25 KB
/
ya-setup
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
#!/bin/bash
#### Author: Snow Dimon ####
#### Website: snowdimon.ru ####
#### modified by SlyTomCat:
#### - adoption to alternative configuration of Yandex Disk daemon
#### - addes quotes around config values
#### modified by Ivan Burmin:
#### - multi-language support
### Command line positional argument: $1 - configfile path
if [ $# -eq 1 ];then
conf=$1
else
conf="/home/$USER/.config/yandex-disk/config.cfg"
fi
### Language
lang_home="/usr/share/yd-tools/translations"
lang_file="$lang_home/ya-setup-$(echo $LANG | cut -c 1-2).lang"
if [ ! -f $lang_file ]; then
lang_file="$lang_home/ya-setup-en.lang"
fi
source $lang_file
###Proxy
ans=$(zenity --list --cancel-label="$_Exit" --ok-label="$_Next" --title "$_YD_setup_title" --text "$_Welcome1 $conf.$_Welcome2" --radiolist --hide-header --column "" --column "$_Options" TRUE "$_No" FALSE "$_Yes" FALSE "$_System_set")
if [ $? -eq "0" ];then
if [ "$ans" = "$_No" ]; then
echo "proxy=\"no\"" > $conf
else
if [ "$ans" = "$_System_set" ]; then
echo "proxy=\"auto\"" > $conf
else
if [ "$ans" = "$_Yes" ]; then
echo "proxy=\"`zenity --entry --title="$_Proxy_title" --text="$_Proxy_body" \
--entry-text="https,127.0.0.1,443,login,password"`\"" > $conf
fi
fi
fi
else
exit 1
fi
###Folder
ans=$(zenity --list --cancel-label="$_Exit" --ok-label="$_Next" --title "$_YD_setup_title" --text "$_Folder_body" --radiolist --hide-header --column "" --column "$_Options" TRUE "$_Default" FALSE "$_Existing")
if [ $? -eq "0" ];then
if [ "$ans" = "$_Default" ]; then
mkdir /home/$USER/Yandex.Disk
echo "dir=\"/home/$USER/Yandex.Disk\"" >> $conf
else
if [ "$ans" = "$_Existing" ]; then
folder=`zenity --file-selection --directory --title="$_Select_folder"`
echo "dir=\"$folder\"" >> $conf
fi
fi
else
exit 1
fi
###Token
auth=$(zenity --entry --title="$_Token_title" --text="$_Token_body" --entry-text="/home/$USER/.config/yandex-disk/passwd")
echo auth=\"$auth\" >> $conf
ENTRY=`zenity --password --username --title="$_YD_setup_title"`
if [ $? -eq "0" ];then
echo $ENTRY | cut -d'|' -f2 | yandex-disk -a $auth token `echo $ENTRY | cut -d'|' -f1` | cut -d':' -f2 | zenity --text-info --width=350 --height=200 --title="$_YD_auth_title"
exit 0
else
exit 1
fi
##############################