-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure_rpi.sh
103 lines (91 loc) · 3.54 KB
/
configure_rpi.sh
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
#!/bin/bash -x
# Скрипт настройки Raspberry Pi с нуля. Устанавливает и настраивает всё то, что можно сделать через скрипт.
# Использовать согласно инструкции https://github.com/ZatolokinPavel/RPiNotes
echo "Raspberry Pi configuration starts"
# configure Device Tree Overlays
sudo sh -c "echo '' >> /boot/firmware/config.txt"
sudo sh -c "echo 'dtoverlay=disable-wifi' >> /boot/firmware/config.txt"
sudo sh -c "echo 'dtoverlay=disable-bt' >> /boot/firmware/config.txt"
sudo systemctl disable hciuart
sudo sh -c "echo 'dtparam=act_led_activelow=on' >> /boot/firmware/config.txt"
sudo sh -c "echo 'dtoverlay=gpio-shutdown,gpio_pin=21' >> /boot/firmware/config.txt"
sudo sh -c "echo 'dtoverlay=gpio-fan,gpiopin=26,temp=60000' >> /boot/firmware/config.txt"
sudo sh -c "echo 'dtoverlay=i2c-rtc,ds3231' >> /boot/firmware/config.txt"
# Disk partitioning
sudo parted /dev/mmcblk0 resizepart 2 17453MB
sudo resize2fs /dev/mmcblk0p2
sudo parted /dev/mmcblk0 -- mkpart primary ext4 17GB -1s
sudo mkfs.ext4 -L okdisk /dev/mmcblk0p3
# update all
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get upgrade
sudo apt-get clean
sudo apt-get autoremove
sudo apt-get autoclean
# install some programs
sudo apt-get install vim git htop i2c-tools
# mc
sudo apt-get install mc crudini
mkdir -p ~/.config/mc
touch ~/.config/mc/ini
crudini --set ~/.config/mc/ini Panels navigate_with_arrows true
crudini --set ~/.config/mc/ini Midnight-Commander skin dark
sudo -u root mkdir -p /root/.config/mc
sudo -u root touch /root/.config/mc/ini
sudo crudini --set /root/.config/mc/ini Panels navigate_with_arrows true
sudo crudini --set /root/.config/mc/ini Midnight-Commander skin dark
# partition mount
sudo mkdir /mnt/okdisk/
sudo sh -c "cat << EOF > /etc/systemd/system/mnt-okdisk.mount
[Unit]
Description=OkFILM global share
[Mount]
What=/dev/mmcblk0p3
Where=/mnt/okdisk
Type=ext4
Options=defaults
DirectoryMode=0755
[Install]
WantedBy=multi-user.target
EOF"
sudo sh -c "cat << EOF > /etc/systemd/system/mnt-okdisk.automount
[Unit]
Description=OkFILM global share
[Automount]
Where=/mnt/okdisk
[Install]
WantedBy=multi-user.target
EOF"
sudo systemctl enable mnt-okdisk.mount
sudo systemctl enable mnt-okdisk.automount
sudo mount /dev/mmcblk0p3 /mnt/okdisk
# Nginx
sudo apt-get install nginx
sudo git clone https://github.com/ZatolokinPavel/nginx.git /srv/nginx
sudo mkdir /srv/logs
sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /srv/nginx/nginx.cfg /etc/nginx/sites-enabled/okfilm.com.ua
sudo mkdir /etc/nginx/includes
sudo ln -s /srv/nginx/includes/ /etc/nginx/includes/okfilm
sudo nginx -s reload
# letsencrypt SSL (https) (not all commands)
sudo apt-get install certbot
sudo crudini --set /etc/letsencrypt/cli.ini '' authenticator webroot
sudo crudini --set /etc/letsencrypt/cli.ini '' webroot-path '/var/www/html'
sudo crudini --set /etc/letsencrypt/cli.ini '' post-hook 'nginx -s reload'
sudo crudini --set /etc/letsencrypt/cli.ini '' text True
sudo mkdir -p /var/www/html/.well-known/acme-challenge
# site okfilm.com.ua
sudo git clone https://github.com/ZatolokinPavel/okfilm_2018.git /srv/okfilm_2018
sudo mkdir /srv/cdn
sudo mkdir /mnt/okdisk/shared-global
sudo chmod 777 /mnt/okdisk/shared-global
sudo ln -s /mnt/okdisk/shared-global/ /srv/shared-global
# erlang 23.2.6
sudo apt-get install erlang
#wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
#sudo dpkg -i erlang-solutions_2.0_all.deb
#rm -f erlang-solutions_2.0_all.deb
#sudo apt-get update
#sudo apt-get install esl-erlang=1:22.1.6-1