-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
120 lines (111 loc) · 4.52 KB
/
install.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
###### Scripts Variables
NEWUSER = "delta"
PASSWORD = "password"
PUBKEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCICDoINxsKkkHq4og/M9g4fiV5F7rf9zJeZtw8Isf+vz1yGEPbJ2y6w5N6shS3D9hQR6+su2h6nhq4ejdRNsHYiZvcGvp9HdsGdOjFgMn6RuzoiUCIN6zkgBb8o2NgGy0wMVPzq9OVcappxt0NjbSRom+wSmsiSASY56n5JoaELdvm3gTsHpyVRilgRodvXaWYn680PF1jaO8qZypo/eQp7NoDPwB0aAB3MDEnmbNwCEBvi1QW+AHYaOWRY7Xop5oo3uxncWrj38TimeFYqSP0so6Bx3sdTYLBzhwMEs7nKKuvJgZ9337TbmPOO+forD26lAC2jm6sBVbWJwzUivhGJW1a71pgFhm8FjK62xJy/cEesASxRMEhM9WaIo7vdw2WZnf/IzTHfDLs3OpQjQhckVaBYO0UMP6ClIvOiEn/sC+jeI4LrObGbGKBa8HYEC9BCPHrQPaIwNW81aRHnK0nFqii0nKaVKGAi4oPtuPmbueIkeVNu/Gxm/6VTnwQZkw3h32HzqlcxYjr5ewPaoMg3A5BfIRR/Kx5G01V74u02QBWL+wo9WukeRHSdXWdPajVVtgKsWjL93R9jJZWChjEfD1p1dgKEreuiJQ8cCBCZcwNYJTo7HEjLXGDiNh8pKMrPduQqn1A0l/VInjDPiOjEFsjuWlg5SgTUtPKqLcNQ== delta@T7500-Workstation"
bashthemeurl = "https://gist.githubusercontent.com/rickdaalhuizen90/d1df7f6042494b982db559efc01d9557/raw/488d28c1b614617025b6dc9d8da1075eedb892d4/.bashrc"
###### Checking If the user is Root
if ! [ $(id -u) = 0 ]; then
echo "I am not root!"
exit 1
fi
echo "I am installing your raspberry All depency and I will uninstall all unused packages"
###### Checking If their is an internet Connection
echo "Checking Internet connection"
if ping -q -c 1 -W 1 google.com >/dev/null; then
echo "The network is up"
else
echo "The network is down"
exit 1
fi
##### Installing And configuring Samba
samba_config() {
apt update
apt install samba -yf
cp /data/configs-file/Samba/smb.conf /etc/samba/smb.conf
systemctl restart nmbd
systemctl restart smbd
}
##### Installing And configuring Nginx
nginx_config(){
apt update
apt install nginx -yf
cp /data/configs-file/Nginx/* /etc/nginx/sites-available/
ln -s /etc/nginx/sites-available/* /etc/nginx/sites-enabled/
nginx -t
systemctl reload nginx
}
###### mount at boot the USB drive on /data
data_disk_mount(){
mkdir /data
apt-get install ntfs-3g
echo "/dev/sda1 /data ntfs defaults,auto,users,rw,nofail,umask=000 0 0" >> /etc/fstab
mount -a
}
###### Installing update
update_and_clean() {
apt update
apt upgrade -yf
apt autoremove -yf
}
###### Installing Zram Swap
zram_install() {
echo "Installing Zram Swap"
apt-get install git -yf
cd /tmp/
git clone https://github.com/StuartIanNaylor/zram-swap-config \
&& cd zram-swap-config
chmod +x install.sh && ./install.sh
cd .. && rm -rfd zram-swap-config
echo "MEM_FACTOR=70
DRIVE_FACTOR=350
COMP_ALG=lz4
SWAP_DEVICES=4
SWAP_PRI=75
PAGE_CLUSTER=0
SWAPPINESS=80" > /etc/zram-swap-config.conf
}
###### Installing Docker
docker_install() {
echo "Adding docker Repo and installing it"
apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -yf
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-compose -yf
usermod -aG docker $NEWUSER
docker network create --driver macvlan --attachable --subnet=192.168.1.120/24 --gateway=192.168.1.254 -o parent=eth0 --ip-range=192.168.1.150/30 macvtap
docker network create --driver bridge --subnet=192.168.128.0/24 --gateway=192.168.128.254 TelegrambotNetwork
docker network create --driver bridge --subnet=172.128.0.0/16 --gateway=172.128.255.254 websitenetwork
docker run -d -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
}
###### Clening the installation
clean_ubuntu_base() {
echo "Updating package list in Repo"
apt update
echo "Removing unused packages"
apt purge -yf lxd lvm2 unattended-upgrades cloud-init snapd docker docker-engine docker.io containerd runc
rm -rfd /etc/cloud
}
###### Changing The user and Adding The ssh pubkey
user_config(){
echo "Changing User to $USER and the password"
usermod -l $NEWUSER ubuntu
usermod -m -d /home/$NEWUSER $NEWUSER
echo -e "$PASSWORD\n$PASSWORD" | passwd $NEWUSER
echo "Changing the bash theme"
curl ${bashthemeurl} > /home/$NEWUSER/.bashrc
echo "Adding SSH pubkey"
mkdir /home/$NEWUSER/.ssh/
echo $PUBKEY > /home/$NEWUSER/.ssh/authorized_keys
}
user_config
clean_ubuntu_base
echo "spearhead" > /etc/hostname
docker_install
zram_install
update_and_clean
data_disk_mount
nginx_config
samba_config