-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathsetup.sh
executable file
·145 lines (120 loc) · 6.12 KB
/
setup.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
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
################################################################################
# Author: Fred ([email protected])
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
echo "#############################################"
echo ">>>>>>>>>>> SYSTEM SETUP "
echo "#############################################"
#### SETUP JAKLIS ###############################################################
echo "=== SETUP jaklis"
cd ~/.zen/Astroport.ONE/tools/jaklis
./setup.sh
## XBIAN fail2ban ERROR correction ##
#[....] Starting authentication failure monitor: fail2ban No file(s) found for glob /var/log/auth.log
[[ "$USER" == "xbian" ]] && sudo sed -i "s/auth.log/faillog/g" /etc/fail2ban/paths-common.conf
# PERSONNAL DEFCON LEVEL
# cp ~/.zen/Astroport.ONE/DEFCON ~/.zen/
mkdir -p ~/.zen/tmp
########################################################################
# open_with_linux.py install
#######################################################################
# DEPRECATED
#~ echo "#############################################"
#~ ## https://darktrojan.github.io/openwith/webextension.html"
#~ ~/.zen/Astroport.ONE/open_with_linux.py install
#~ echo "#############################################
#~ # NOURRISSEZ VOTRE BLOB depuis Firefox !!
#~ # https://addons.mozilla.org/firefox/addon/open-with
#~ #############################################
#~ ## $HOME/.zen/Astroport.ONE/ajouter_media.sh ##
#~ #############################################"
########################################################################
# SUDO permissions
########################################################################
## USED FOR RAMDISK (video live streaming)
## USED FOR SYSTEM UPGRADE
## USED FOR "systemctl restart ipfs"
## USED FOR "sudo youtube-dl -U"
for bin in fail2ban-client mount umount apt-get apt systemctl yt-dlp; do
binpath=$(which $bin)
[[ -x $binpath ]] \
&& echo "$USER ALL=(ALL) NOPASSWD:$binpath" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/'$bin) \
&& echo "SUDOERS RIGHT SET FOR : $binpath" \
|| echo "ERROR MISSING $bin"
done
### MODIFIYING /etc/sudoers ###
[[ "$USER" == "xbian" ]] && echo "xbian ALL=(ALL) NOPASSWD:ALL" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/astroport')
echo "#############################################"
echo "# ADDING <<<Astroport & REC >>> DESKTOP SHORTCUT"
[[ -d ~/Bureau ]] && sed "s/_USER_/$USER/g" ~/.zen/Astroport.ONE/astroport.desktop > ~/Bureau/astroport.desktop && chmod +x ~/Bureau/astroport.desktop
[[ -d ~/Desktop ]] && sed "s/_USER_/$USER/g" ~/.zen/Astroport.ONE/astroport.desktop > ~/Desktop/astroport.desktop && chmod +x ~/Desktop/astroport.desktop
[[ -d ~/Bureau ]] && sed "s/_USER_/$USER/g" ~/.zen/Astroport.ONE/rec.desktop > ~/Bureau/rec.desktop && chmod +x ~/Bureau/rec.desktop
[[ -d ~/Desktop ]] && sed "s/_USER_/$USER/g" ~/.zen/Astroport.ONE/rec.desktop > ~/Desktop/rec.desktop && chmod +x ~/Desktop/rec.desktop
[[ -d ~/Bureau ]] && sed "s/_USER_/$USER/g" ~/.zen/Astroport.ONE/g1billet.desktop > ~/Bureau/g1billet.desktop && chmod +x ~/Bureau/g1billet.desktop
[[ -d ~/Desktop ]] && sed "s/_USER_/$USER/g" ~/.zen/Astroport.ONE/g1billet.desktop > ~/Desktop/g1billet.desktop && chmod +x ~/Desktop/g1billet.desktop
######### SUPER PRATIQUE :: DOES NOT WORK WITH SPACE IN FILENAME
echo "# ADD NEMO 'Add To IPFS' ACTION"
~/.zen/Astroport.ONE/tools/install.nemo.add2ipfs.sh
echo "CREATE SYSTEMD astroport SERVICE >>>>>>>>>>>>>>>>>>"
cat > /tmp/astroport.service <<EOF
[Unit]
Description=ASTROPORT API
After=network.target
Requires=network.target
[Service]
Type=idle
User=_USER_
RestartSec=1
Restart=always
ExecStart=/home/_USER_/.zen/Astroport.ONE/12345.sh
StandardOutput=file:/home/_USER_/.zen/tmp/12345.log
[Install]
WantedBy=multi-user.target
EOF
sudo cp -f /tmp/astroport.service /etc/systemd/system/
sudo sed -i "s/_USER_/$USER/g" /etc/systemd/system/astroport.service
sudo systemctl daemon-reload
sudo systemctl enable astroport
sudo systemctl restart astroport
ACTUAL=$(cat /etc/resolv.conf | grep -w nameserver | head -n 1)
if [[ $(echo $ACTUAL | grep "1.1.1.1") == "" ]] ; then
########################################################################
echo "ADDING nameserver 1.1.1.1 TO /etc/resolv.conf TO BYPASS COUNTRY RESTRICTIONS" # Avoid provider restrictions
########################################################################
sudo chattr -i /etc/resolv.conf
sudo cat > /tmp/resolv.conf <<EOF
domain home
search home
nameserver 1.1.1.1
$ACTUAL
# ASTROPORT.ONE
EOF
sudo cp /etc/resolv.conf /etc/resolv.conf.backup
sudo mv /tmp/resolv.conf /etc/resolv.conf
sudo chattr +i /etc/resolv.conf
fi
if [[ ! $(cat /etc/hosts | grep -w "astroport.local" | head -n 1) ]]; then
cat /etc/hosts > /tmp/hosts
echo "127.0.1.1 $(hostname) $(hostname).local astroport.$(hostname).local ipfs.$(hostname).local astroport.local duniter.localhost" >> /tmp/hosts
sudo cp /tmp/hosts /etc/hosts && rm /tmp/hosts
fi
### ADD 20h12.sh CRON ###############
~/.zen/Astroport.ONE/tools/cron_VRFY.sh ON
echo "##INSTALL yt-dlp & SYMLINK youtube-dl ##########################"
~/.zen/Astroport.ONE/youtube-dl.sh
echo "... Optimizing security into /etc/ssh/sshd_config"
# Sauvegarde du fichier original
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
# Effectue les modifications en utilisant sed
sudo sed -i 's/^.*PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_config
sudo sed -i 's/^.*PermitEmptyPasswords .*/PermitEmptyPasswords no/' /etc/ssh/sshd_config
sudo sed -i 's/^.*ChallengeResponseAuthentication .*/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config
sudo sed -i 's/^.*PubkeyAuthentication .*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
sudo sed -i 's/^.*X11Forwarding .*/X11Forwarding yes/' /etc/ssh/sshd_config
sudo sed -i 's/^.*ClientAliveInterval .*/ClientAliveInterval 60/' /etc/ssh/sshd_config
sudo sed -i 's/^.*ClientAliveCountMax .*/ClientAliveCountMax 3/' /etc/ssh/sshd_config