#!/bin/bash
# Variables
Domain="mi.local" # se puede cambiar
IPHOST=$(ip a | grep inet | grep -v 'inet6' | grep -v 'host lo' | tr ' ' '/' | cut -d '/' -f6)
ETH=$(ip a | grep -B 2 "$IPHOST" | head -n1 | cut -d ':' -f2 | tr -d ' ')
IPNet=$(ip a | grep inet | grep -v 'inet6' | grep -v 'host lo' | tr ' ' '/' | cut -d '/' -f6,7)
#Version AP.
Title="AP.2.0 - maxi"
# detect installation default User
User=$(cat /etc/passwd | grep "1000:1000:" | cut -d ':' -f1)
DefaultHome="/home/$User"
#echo DefaultHome=$DefaultHome
StartID=$(cat /etc/passwd | grep $User | cut -d ':' -f3)
StartGroup=$(cat /etc/group | grep "$StartID" | cut -d ':' -f1)
#echo StartID=$StartID
#echo StartGroup=$StartGroup
if [ -d /usr/local/ispconfig ]; then
clear
echo "ispconfig exist, I can't follow"
exit 1
fi
testing() {
##### TESTING @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
sed -i "s|192.168.0.103 www.preparandonos.es||" /etc/hosts
echo "192.168.0.103 www.preparandonos.es" >> /etc/hosts
export DEBIAN_FRONTEND=noninteractive
apt install mc debfoster openssh-server -y
debfoster -q
DATE=$(date '+%Y-%m-%d_%H.%M.%S')
mkdir -p /root/DebFoster
cp /var/lib/debfoster/keepers /root/DebFoster/keepers_$DATE
}
cleanSystem() {
clear
cp $(ls /root/DebFoster/keepers* | head -n1) /var/lib/debfoster/keepers
echo "quidado esto va a resetear la instalación"
debfoster -f
rm -rf /home/$User/public_html
rm -rf /var/www
rm -rf /etc/apache2
cat /etc/hosts | grep -v "127.0.1.1" |\
grep -v "$Domain" > /tmp/hosts
mv /tmp/hosts /etc/hosts
echo "127.0.1.1 $(cat /etc/hostname)" >> /etc/hosts
cat /etc/chrony/chrony.conf | grep -v "NMEA" > /tmp/chrony.conf
mv /tmp/chrony.conf /etc/chrony/chrony.conf
rm -rf /home/$User/Wikipedias
rm /etc/systemd/system/kiwix.service
rm -rf /usr/local/yacy
rm /etc/systemd/system/yacy.service
echo "terminado"
exit
}
TEST=0
if [ $TEST = 1 ]; then
testing
fi
if [ "$1" == "CLEAN" ]; then
cleanSystem
fi
###############################################
mkdir -p $DefaultHome/public_html/Docs
mkdir -p $DefaultHome/public_html/Sites
mkdir -p $DefaultHome/public_html/You2Pub
mkdir -p $DefaultHome/public_html/Apps
chmod 755 $DefaultHome
chmod -R 755 $DefaultHome/public_html
chown -R $User.$StartGroup $DefaultHome/public_html
apt update && apt upgrade -y
#apt install htop debfoster -y
#debfoster -q
ISPConfig() {
cd /usr/src
# wget -O - https://get.ispconfig.org | -s sh -s -- --unattended-upgrades --no-dns --use-unbound --use-certbot --no-mailman --no-quota --no-ntp --i-know-what-i-am-doing
wget https://get.ispconfig.org -O get.ispconfig.sh
sh ./get.ispconfig.sh --unattended-upgrades --use-certbot --no-mailman --no-quota --no-ntp --i-know-what-i-am-doing
cat /tmp/ispconfig-ai/var/log/setup-*.log | grep -A1 "Your ISPConfig admin password is" | cut -d ':' -f5-6 > /tmp/passwords.txt
echo "Admin URL = https://localhost:8080" >> /tmp/passwords.txt
cp /tmp/passwords.txt $DefaultHome
chown $User:$StartGroup $DefaultHome/passwords.txt
#rm /tmp/passwords.txt
#rm -rf /tmp/ispconfig-ai
# chmod 666 *.txt
# cp /root/*.txt /
}
VirtualHost() {
# virtualhost-apache
mkdir -p /var/www/$Domain
chown www-data.www-data /var/www/$Domain
chmod 775 /var/www/$Domain
echo "
# create new for [virtual.host]
ServerName $Domain
ServerAdmin $User@$Domain
DocumentRoot /var/www/$Domain
ErrorLog /var/log/apache2/$Domain.error.log
CustomLog /var/log/apache2/$Domain.access.log combined
LogLevel warn
ServerName $Domain
ServerAdmin $User@$Domain
DocumentRoot /var/www/$Domain
ErrorLog /var/log/apache2/$Domain.error.log
CustomLog /var/log/apache2/$Domain.access.log combined
LogLevel warn
SSLEngine on
SSLCertificateFile /etc/ssl/$Domain/$Domain+4.pem
SSLCertificateKeyFile /etc/ssl/$Domain/$Domain+4-key.pem
" > /etc/apache2/sites-available/$Domain.conf
echo "
$Title
$Title
" > /var/www/$Domain/index.html
a2ensite $Domain
systemctl reload apache2
echo "127.0.0.1 $Domain" >> /etc/hosts
# yacy
mkdir -p /var/www/yacy.$Domain
chown www-data.www-data /var/www/yacy.$Domain
chmod 775 /var/www/yacy.$Domain
echo "
# create new for [virtual.host]
ServerName yacy.$Domain
ServerAdmin $User@$Domain
DocumentRoot /var/www/yacy.$Domain
ErrorLog /var/log/apache2/yacy.$Domain.error.log
CustomLog /var/log/apache2/yacy.$Domain.access.log combined
LogLevel warn
ProxyPass / http://127.0.0.1:8090/
ProxyPassReverse / http://127.0.0.1:8090/
ServerName yacy.$Domain
ServerAdmin $User@$Domain
DocumentRoot /var/www/yacy.$Domain
ErrorLog /var/log/apache2/yacy.$Domain.error.log
CustomLog /var/log/apache2/yacy.$Domain.access.log combined
LogLevel warn
ProxyPass / http://127.0.0.1:8090/
ProxyPassReverse / http://127.0.0.1:8090/
SSLEngine on
SSLCertificateFile /etc/ssl/$Domain/$Domain+4.pem
SSLCertificateKeyFile /etc/ssl/$Domain/$Domain+4-key.pem
" > /etc/apache2/sites-available/yacy.$Domain.conf
a2ensite yacy.$Domain
systemctl reload apache2
echo "127.0.0.1 yacy.$Domain" >> /etc/hosts
# kiwix-wikipedia
mkdir -p /var/www/wiki.$Domain
chown www-data.www-data /var/www/wiki.$Domain
chmod 775 /var/www/wiki.$Domain
echo "
# create new for [virtual.host]
ServerName wiki.$Domain
ServerAdmin $User@$Domain
DocumentRoot /var/www/wiki.$Domain
ErrorLog /var/log/apache2/wiki.$Domain.error.log
CustomLog /var/log/apache2/wiki.$Domain.access.log combined
LogLevel warn
ProxyPass / http://127.0.0.1:8082/
ProxyPassReverse / http://127.0.0.1:8082/
ServerName wiki.$Domain
ServerAdmin $User@$Domain
DocumentRoot /var/www/wiki.$Domain
ErrorLog /var/log/apache2/wiki.$Domain.error.log
CustomLog /var/log/apache2/wiki.$Domain.access.log combined
LogLevel warn
ProxyPass / http://127.0.0.1:8082/
ProxyPassReverse / http://127.0.0.1:8082/
SSLEngine on
SSLCertificateFile /etc/ssl/$Domain/$Domain+4.pem
SSLCertificateKeyFile /etc/ssl/$Domain/$Domain+4-key.pem
" > /etc/apache2/sites-available/wiki.$Domain.conf
a2ensite wiki.$Domain
systemctl reload apache2
echo "127.0.0.1 wiki.$Domain" >> /etc/hosts
}
prepare() {
service systemd-resolved stop
systemctl disable systemd-resolved
service named stop
systemctl disable named
rm /etc/resolv.conf
echo "
nameserver 8.8.8.8
nameserver 1.1.1.1" > /tmp/resolv.conf
mv /tmp/resolv.conf /etc
}
#installPacks() {
# apt install mc pandoc firefox zenity chrony debfoster htop iotop dnsmasq gpsd-tools gpsd-clients chirp js8call fldigi sox jq dwww wkhtmltopdf bindfs wget curl python3-pip -y
# pip3 install yt-dlp
#}
installPacks() {
export DEBIAN_FRONTEND=noninteractive
apt install mc wget firefox zenity mkcert chrony dialog gpsd-tools dnsmasq gpsd-clients chirp qsstv js8call fldigi sox ffmpeg jq dwww wkhtmltopdf bindfs curl python3-pip pandoc zenity -y
pip3 install yt-dlp
sed -i 's|#user_allow_other|user_allow_other|' /etc/fuse.conf
apt remove lighttpd radioclk -y
service resolvconf stop
systemctl disable resolvconf
service dnsmasq restart
}
gpsTime() {
# GPS TIME
echo "# Devices gpsd should collect to at boot time.
START_DAEMON=\"true\"
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES=\"/dev/ttyACM0\"
# Other options you want to pass to gpsd
GPSD_OPTIONS=\"-n\"
# Automatically hot add/remove USB GPS devices via gpsdctl
USBAUTO=\"true\"" > /etc/defaults/gpsd
cat /etc/chrony/chrony.conf | grep -v "refid NMEA" > /tmp/chrony.conf
mv /tmp/chrony.conf /etc/chrony/chrony.conf
echo "refclock SHM 0 offset 0.5 delay 0.2 refid NMEA" >> /etc/chrony/chrony.conf
}
mcEnv() {
# MC
echo "Configuring MC for user: $User"
mkdir -p /home/$User/.config/mc
echo "[Midnight-Commander]
verbose=true
shell_patterns=true
auto_save_setup=true
preallocate_space=false
auto_menu=false
use_internal_view=true
use_internal_edit=false
clear_before_exec=true
confirm_delete=true
confirm_overwrite=true
confirm_execute=false
confirm_history_cleanup=true
confirm_exit=false
confirm_directory_hotlist_delete=false
confirm_view_dir=false
safe_delete=false
safe_overwrite=false
use_8th_bit_as_meta=false
mouse_move_pages_viewer=true
mouse_close_dialog=false
fast_refresh=false
drop_menus=false
wrap_mode=true
old_esc_mode=true
cd_symlinks=true
show_all_if_ambiguous=false
use_file_to_guess_type=true
alternate_plus_minus=false
only_leading_plus_minus=true
show_output_starts_shell=false
xtree_mode=false
file_op_compute_totals=true
classic_progressbar=true
use_netrc=true
ftpfs_always_use_proxy=false
ftpfs_use_passive_connections=true
ftpfs_use_passive_connections_over_proxy=false
ftpfs_use_unix_list_options=true
ftpfs_first_cd_then_ls=true
ignore_ftp_chattr_errors=true
editor_fill_tabs_with_spaces=false
editor_return_does_auto_indent=false
editor_backspace_through_tabs=false
editor_fake_half_tabs=true
editor_option_save_position=true
editor_option_auto_para_formatting=false
editor_option_typewriter_wrap=false
editor_edit_confirm_save=true
editor_syntax_highlighting=true
editor_persistent_selections=true
editor_drop_selection_on_copy=true
editor_cursor_beyond_eol=false
editor_cursor_after_inserted_block=false
editor_visible_tabs=true
editor_visible_spaces=true
editor_line_state=false
editor_simple_statusbar=false
editor_check_new_line=false
editor_show_right_margin=false
editor_group_undo=true
editor_state_full_filename=true
editor_ask_filename_before_edit=false
nice_rotating_dash=true
shadows=true
mcview_remember_file_position=false
auto_fill_mkdir_name=true
copymove_persistent_attr=true
pause_after_run=1
mouse_repeat_rate=100
double_click_speed=250
old_esc_mode_timeout=1000000
max_dirt_limit=10
num_history_items_recorded=60
vfs_timeout=60
ftpfs_directory_timeout=900
ftpfs_retry_seconds=30
fish_directory_timeout=900
editor_tab_spacing=8
editor_word_wrap_line_length=72
editor_option_save_mode=0
editor_backup_extension=~
editor_filesize_threshold=64M
editor_stop_format_chars=-+*\\,.;:&>
mcview_eof=
skin=gotar
filepos_max_saved_entries=1024
[Layout]
output_lines=0
left_panel_size=75
top_panel_size=0
message_visible=true
keybar_visible=true
xterm_title=true
command_prompt=true
menubar_visible=true
free_space=true
horizontal_split=false
vertical_equal=true
horizontal_equal=true
[Misc]
timeformat_recent=%e %b %H:%M
timeformat_old=%e %b %Y
ftp_proxy_host=gate
ftpfs_password=anonymous@
display_codepage=UTF-8
source_codepage=Other_8_bit
autodetect_codeset=
spell_language=en
clipboard_store=
clipboard_paste=
[Colors]
base_color=
xterm-256color=
color_terminals=
[Panels]
show_mini_info=true
kilobyte_si=false
mix_all_files=false
show_backups=true
show_dot_files=true
fast_reload=false
fast_reload_msg_shown=false
mark_moves_down=true
reverse_files_only=true
auto_save_setup_panels=false
navigate_with_arrows=true
panel_scroll_pages=true
panel_scroll_center=false
mouse_move_pages=true
filetype_mode=true
permission_mode=false
torben_fj_mode=false
quick_search_mode=2
select_flags=6
simple_swap=false
[Panelize]
Archivos git modificados=git ls-files --modified
Buscar archivos originales después de aplicar parches=find . -name \\*.orig -print
Buscar archivos rechazados después de aplicar parches=find . -name \\*.rej -print
Buscar programas con SUID y SGID=find . \\( \\( -perm -04000 -a -perm /011 \\) -o \\( -perm -02000 -a -perm /01 \\) \\) -print" > /home/$User/.config/mc/ini
chmod 666 /home/$User/.config/mc/ini
echo "[New Left Panel]
display=listing
reverse=false
case_sensitive=true
exec_first=false
sort_order=name
list_mode=full
brief_cols=2
user_format=half type name | size | perm
user_status0=half type name | size | perm
user_status1=half type name | size | perm
user_status2=half type name | size | perm
user_status3=half type name | size | perm
user_mini_status=false
list_format=full
[New Right Panel]
display=listing
reverse=false
case_sensitive=true
exec_first=false
sort_order=name
list_mode=full
brief_cols=2
user_format=half type name | size | perm
user_status0=half type name | size | perm
user_status1=half type name | size | perm
user_status2=half type name | size | perm
user_status3=half type name | size | perm
user_mini_status=false
list_format=full
[Dirs]
current_is_left=true
other_dir=/root
" > /home/$User/.config/mc/panels.ini
chmod 666 /home/$User/.config/mc/panels.ini
cp -R /home/$User/.config/mc /root/.config/
}
Kiwix() {
export DEBIAN_FRONTEND=noninteractive
apt install kiwix-tools -y
mkdir -p /home/$User/public_html/Wikipedias
chmod 755 /home/$User/Wikipedias
cd /home/$User/public_html/Wikipedias
wget -c https://download.kiwix.org/zim/gutenberg/gutenberg_ale_all_2022-03.zim
kiwix-manage library.xml add *.zim
echo "[Unit]
Description=Kiwix
After=network.target
[Service]
Restart=on-failure
RestartSec=5s
Type=forking
ExecStart=/usr/bin/kiwix-serve --library /home/$User/public_html/Wikipedias/library.xml --port 8082 --daemon -M
[Install]
WantedBy=multi-user.target
" > /tmp/kiwix.service
mv /tmp/kiwix.service /etc/systemd/system/kiwix.service
systemctl enable kiwix.service
mv /home/Kiwix/*.zim /home/$User/Wikipedias/ 2>/dev/null
mv /home/Kiwix/library.xml /home/$User/Wikipedias/ 2>/dev/null
chown -R $User.$StartGroup /home/$User/Wikipedias 2>/dev/null
service kiwix start
}
Yacy() {
apt-get install -y openjdk-8-jre-headless
cd /usr/src
wget https://download.yacy.net/yacy_v1.924_20210209_10069.tar.gz
tar xfz yacy_v1.924_20210209_10069.tar.gz
mv /usr/src/yacy /usr/local
mkdir -p /home/$User/public_html/yacy/DATA
ln -s /home/$User/public_html/yacy/DATA /usr/local/yacy/DATA
echo "
[Unit]
Description=YaCy search server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/yacy/startYACY.sh
ExecStop=/usr/local/yacy/stopYACY.sh
[Install]
WantedBy=multi-user.target
" > /usr/src/yacy.service
mv /usr/src/yacy.service /etc/systemd/system/yacy.service
systemctl enable yacy.service
service yacy start
}
DeltaChat() {
wget "https://delta.chat/es/download" -O /usr/src/delta
DeltaUrl=$(cat /usr/src/delta | grep "amd64.deb" | cut -d '"' -f2)
cd /usr/src
wget "$DeltaUrl"
dpkg -i deltachat*.deb
export DEBIAN_FRONTEND=noninteractive
apt install -f -y
}
Apache2() {
mkdir $HOME/public_html
chmod 755 $HOME/public_html
chmod 755 $HOME
echo "^ UserDir public_html^ UserDir disabled root^^ ^ #AllowOverride FileInfo AuthConfig Limit Indexes^ #Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec^ #Require method GET POST OPTIONS^ Options Indexes MultiViews^ AllowOverride None^ Require all granted^ ^^^# vim: syntax=apache ts=4 sw=4 sts=4 sr noet^" | tr '^' '\n' > /etc/apache2/mods-available/userdir.conf
a2enmod autoindex userdir
systemctl restart apache2
}
Urls() {
#### Write URLs file
echo "**URLS**
----------------------------------
ISPConfig (admin)
https://127.0.0.1:8080
Apache Directives:
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
----------------------------------
kiwix (wikipedia)
http://127.0.0.1:8082
Apache Directives:
ProxyPass / http://127.0.0.1:8082/
ProxyPassReverse / http://127.0.0.1:8082/
----------------------------------
Yacy (Search engine)
http://127.0.0.1:8090
Apache Directives:
ProxyPass / http://127.0.0.1:8090/
ProxyPassReverse / http://127.0.0.1:8090/
----------------------------------
" > /home/$User/URLS.txt
chown $User:$StartGroup /home/$User/URLS.txt
#chmod 666 /home/$User/URLS.txt
# cp /home/$User//URLS.txt /
}
sethostname() {
# hostname / hosts
hostnamectl set-hostname www.apocalipsis.local
cat /etc/hosts | grep -v "127.0.1.1 www.apocalipsis.local" |\
grep -v "$Domain" > /tmp/hosts
echo "127.0.1.1 www.apocalipsis.local" >> /tmp/hosts
mv /tmp/hosts /etc/hosts
}
CA() {
export DEBIAN_FRONTEND=noninteractive
apt install mkcert -y
mkdir -p /etc/ssl/$Domain
cd /etc/ssl/$Domain
mkcert $Domain "*.$Domain" localhost 127.0.0.1 ::1
mkdir -p /var/www/$Domain/
cp /root/.local/share/mkcert/rootCA.pem /var/www/$Domain
cp /root/.local/share/mkcert/rootCA.pem /etc/ssl/$Domain
cp /etc/ssl/$Domain/$Domain+4.pem /var/www/$Domain/
}
NewLandingMaxi() {
PASS=$(cat /home/$User/passwords.txt | grep ISP | cut -d ':' -f2 | tr -d ' ')
echo "\"use strict\";
var menu = [
{
\"class\": \"item\",
\"title\": \"Videos\",
\"link\": \"http://$Domain/~$User/You2Pub/\"
},
{
\"class\": \"item\",
\"title\": \"Copias de Paginas Web\",
\"link\": \"http://$Domain/~$User/Sites\"
},
{
\"class\": \"item\",
\"title\": \"Wikipedias\",
\"link\": \"http://wiki.$Domain/\"
},
{
\"class\": \"item\",
\"title\": \"Motor de Busqueda\",
\"link\": \"http://yacy.$Domain:8090/\"
},
{
\"class\": \"item\",
\"title\": \"Documentos\",
\"link\": \"http://$Domain/~$User/Docs/\"
},
{
\"class\": \"item\",
\"title\": \"Aps, Programas y\",
\"link\": \"http://$Domain/~$User/Apps\",
\"line2\": \"Sistemas Operativos\"
},
{
\"class\": \"item admin\",
\"title\": \"Administracion\",
\"link\": \"http://127.0.0.1:8090/Status.html?\",
\"line2\": \"Motor de Busqueda\"
},
{
\"class\": \"item admin\",
\"title\": \"Administracion ISPConfig\",
\"link\": \"http://127.0.0.1:8080\",
\"line2\": \"Contrasena por defecto\",
\"line3\": \"admin / $PASS\"
}
];
function initialize() {
for (var i=0;i /var/www/$Domain/functions.js
echo "
$Title
$Title
" > /var/www/$Domain/index.html
echo "
* {
box-sizing: border-box;
}
[class*=\"col-\"] {
float: left;
width: 99%;
}
.row::after {
content: \"\";
clear: both;
display: table;
}
@media only screen and (min-width: 768px) {
/* for desktoop */
.col-1 {width: 24%;}
.col-2 {width: 49%;}
.col-3 {width: 74%;}
.col-4 {width: 99%;}
}
body {
margin: 0;
font-size: 12pt;
background-color: #404040;
color: #FFFFE0;
width: 100%;
height: 100%;
display: block;
}
.title {
display: block;
background-color: lavender;
color: #000000;
font-size: 2em;
text-align: center;
border: 2px solid #4080FF;
border-radius: 8px;
margin: 8px;
padding: 4px;
}
.search {
font-size: 1em;
padding: 4px;
margin: 8px;
text-align: center;
}
.search form {
background-color: lavender;
color: black;
width: 100%;
margin: auto;
padding: 8px;
border: 1px solid darkgray;
border-radius: 8px;
}
.content {
text-align: center;
}
.item {
min-height: 3em;
padding: 4px;
margin: 4px;
background-color: lightskyblue;
color: #000040;
border: 2px solid royalblue;
border-radius: 8px;
}
.item:hover {
background-color: deepskyblue;
}
.admin {
background-color: goldenrod;
border: 2px solid darkgoldenrod;
}
.admin:hover {
background-color: palegoldenrod;
}
.small {
font-size: 0.75em;
}
.footer {
text-align: center;
background-color: lavander;
color: white;
padding: 8px 4px;
}
.footer a {
color: lightblue;
text-decoration: none;
}
.footer a:hover {
color: cyan;
}
" > /var/www/$Domain/style.css
chown www-data.www-data /var/www/$Domain/*
}
briar() {
cd /usr/src
wget -c https://desktop.briarproject.org/debs/jammy/briar-desktop-ubuntu-22.04.deb
dpkg -i briar-desktop-ubuntu-22.04.deb
apt install -f
}
telegram() {
snap install telegram-desktop
}
bundle() {
Version=21
cd /
wget -c "https://www.preparandonos.es/bundle_$Version.tgz"
tar zxvf bundle_$Version.tgz
mv bundle_$Version.tgz /usr/src
}
###################### start program ################
sethostname
ISPConfig
CA
VirtualHost
prepare
installPacks
mcEnv
Kiwix
Yacy
gpsTime
DeltaChat
Apache2
briar
telegram
bundle
Urls
installPacks # segundo intento en el caso hayas tenidos problemas de conexión a internet
NewLandingMaxi
reboot
#GnomeSW