-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit_raspi
executable file
·144 lines (130 loc) · 4.15 KB
/
init_raspi
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
#Reset color
Color_Off='\e[0m' # Text Reset
#Colors
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
yd_remote_directory="/home/vascom/yandex.disk/"
gd_remote_directory="/home/vascom/google.drive/"
secure_section_from="/home/vascom/yandex.disk/.secure/"
secure_section_to="/home/vascom/secure"
secure_section_check="$secure_section_to/kva/"
secure_ftp_from="/home/vascom/.secure_ftp/"
secure_ftp_to="/home/vascom/secure_ftp/"
secure_ftp_check="$secure_ftp_to/torrents/"
yd_pid_file="/var/run/mount.davfs/home-vascom-yandex.disk.pid"
cd_pid_file="/var/run/chronyd.pid"
cronyd_delay=10
dev_sda1="/dev/disk/by-uuid/7a1bd51b-00d9-4c1c-88d0-9e987097af4e"
dev_sdb1="/dev/disk/by-uuid/acdb5d2e-3a7e-435f-ad53-e999a4723b51"
sda1_mountpoint="/home/vascom/sda1"
sdb1_mountpoint="/home/vascom/sdb1"
sda1_mounted="$sda1_mountpoint/downloads"
function secure_mount() {
if [ ! -e $3 ]
then
echo -ne "Mount ${Red}secure${Color_Off} section? (Y/n) "
read item
case "$item" in
y|Y|"") encfs "$1" "$2"
;;
*) echo "Exit"
;;
esac
fi
}
function yandex_disk_check() {
if [ ! -e $yd_remote_directory/Documents/ ]
then
if [ -e $yd_pid_file ]
then
sudo rm -rf $yd_pid_file
fi
sudo systemctl start home-vascom-yandex.disk.mount
fi
if systemctl status home-vascom-yandex.disk.mount &>/dev/null
then
echo -e "Yandex.Disk ${Green}OK${Color_Off}"
secure_mount $secure_section_from $secure_section_to $secure_section_check
else
echo -e "yandex.disk mount ${Red}FAILED${Color_Off}"
fi
}
function disks_mount_check(){
if [ -e $dev_sdb1 ]
then
sudo mount $dev_sdb1 $sdb1_mountpoint
echo "sdb1 mounted"
fi
if [ -e $dev_sda1 ]
then
if [ ! -e $sda1_mounted ]
then
sudo mount $dev_sda1 $sda1_mountpoint
sudo mount --bind $sda1_mountpoint/downloads downloads/
# sudo mount --bind downloads/ /var/www/lighttpd/downloads
# sudo mount --bind downloads/ /var/ftp/downloads/
# sudo mount --bind public_misc/ /var/www/lighttpd/misc/pictures/
echo "sda1 mounted"
else
echo "sda1 already mounted"
fi
else
echo -e "${Red}Error${Color_Off}: sda1 not connected"
fi
sudo mount --bind downloads/ /var/www/lighttpd/downloads
sudo mount --bind downloads/ /var/ftp/downloads/
sudo mount --bind public_misc/ /var/www/lighttpd/misc/pictures/
}
function google_mount(){
if [ ! -e $gd_remote_directory/Documents/ ]
then
google-drive-ocamlfuse google.drive
echo "Google.Drive mounted"
else
echo -e "Google.Drive ${Green}OK${Color_Off}"
fi
}
# function ftp_check(){
# ftp_status=`ps aux | grep pure-ftpd -c`
# if [ $ftp_status -lt 2 ]
# then
# sudo pure-ftpd -4 -c 10 -C 5 -i -l unix -p 50000:60000 -P vascom.myftp.org -S 8021 -B
# # sudo pure-ftpd --ipv4only --maxclientsnumber 10 --maxclientsperip 5 --anonymouscantupload \
# # -login unix --passiveportrange 50000:60000 --forcepassiveip vascom.myftp.org --bind 8021 --daemonize
# echo "FTP started"
# else
# echo -e "FTP \e[32mOK\e[0m"
# fi
# }
function service_check(){
if ! systemctl status $1 &>/dev/null
then
if [ "$1" == "chronyd" ]
then
sudo rm -f $cd_pid_file
sudo systemctl restart chronyd
echo "$1 restarted"
sleep $cronyd_delay
else
sudo systemctl start $1
echo "$1 started"
fi
else
echo -e "$1 ${Green}OK${Color_Off}"
fi
}
echo "Starting at temperature: `sensors | grep temp | cut -d "+" -f2`"
service_check chronyd
#yandex_disk_check
secure_mount $secure_ftp_from $secure_ftp_to $secure_ftp_check
#google_mount
disks_mount_check
#service_check noip
service_check nfs
service_check lighttpd
service_check pure-ftpd
#ftp_check
#fuse-zip -o allow_other russianfedora.pro.zip /var/www/lighttpd/misc/sites
#cd /var/www/lighttpd/misc/sites
#wget -r -k -l 4 -p -E -nc -np http://russianfedora.pro/logs/