├── .assets
└── motd.png
├── README.md
├── RELEASE
├── daemon_builder
├── berkeley.sh
├── conf
│ ├── daemonbuilder.sh
│ ├── editconf.py
│ ├── getip.sh
│ ├── preflight.sh
│ └── prerequisite.sh
├── install.sh
├── requirements.sh
├── start.sh
└── utils
│ ├── addport.sh
│ ├── create_user.sh
│ ├── menu.sh
│ ├── menu1.sh
│ ├── menu2.sh
│ ├── menu3.sh
│ ├── menu4.sh
│ ├── screen-scrypt-daemonbuilder.sh
│ ├── source.sh
│ ├── start.sh
│ └── stratum.sh
├── install.sh
├── install
├── bootstrap_coin.sh
├── bootstrap_upgrade.sh
├── create_user.sh
├── editconf.py
├── existing_user.sh
├── functions.sh
├── menu.sh
├── pre_setup.sh
├── preflight.sh
└── start.sh
├── yiimp_single
├── compile_crypto.sh
├── daemon.sh
├── db.sh
├── first_boot.sh
├── menu.sh
├── motd.sh
├── nginx_confs
│ ├── general.conf
│ ├── letsencrypt.conf
│ ├── nginx.conf
│ ├── php_fastcgi.conf
│ ├── security.conf
│ ├── site.conf
│ ├── site_self_ssl.conf
│ ├── ssl_nginx_default.conf
│ └── web_default.conf
├── nginx_domain_nonssl.sh
├── nginx_domain_nossl.sh
├── nginx_domain_ssl.sh
├── nginx_subdomain_nonssl.sh
├── nginx_subdomain_ssl.sh
├── nginx_upgrade.sh
├── questions.sh
├── self_ssl.sh
├── send_mail.sh
├── server_cleanup.sh
├── server_harden.sh
├── start.sh
├── stratum.sh
├── system.sh
├── ubuntu
│ ├── blocknotify.sh
│ ├── etc
│ │ └── update-motd.d
│ │ │ ├── 00-header
│ │ │ ├── 10-sysinfo
│ │ │ └── 90-footer
│ ├── screens
│ └── stratum
├── web.sh
├── wireguard.sh
└── yiimp_confs
│ ├── blocks.sh
│ ├── coin_form.php
│ ├── exbitron_trading.php
│ ├── keys.sh
│ ├── loop2.sh
│ ├── main.php
│ ├── main.sh
│ └── yiimpserverconfig.sh
└── yiimp_upgrade
├── menu.sh
├── single.sh
├── start.sh
├── up_stratum.sh
├── up_web.sh
└── upgrade_warning.sh
/.assets/motd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/afiniel/yiimp_install_script/8dea29ddab6f1cb0a9c3345f111fab2c6b42712c/.assets/motd.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Yiimpool Yiimp Installer with DaemonBuilder
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | ## Description
10 |
11 | This installer provides an automated way to set up a full Yiimp mining pool on Ubuntu 18.04/20.04. Key features include:
12 |
13 | - Automated installation and configuration of all required components
14 | - Built-in DaemonBuilder for compiling coin daemons
15 | - Multiple SSL configuration options (Let's Encrypt or self-signed)
16 | - Support for both domain and subdomain setups
17 | - Enhanced security features and server hardening
18 | - Automatic stratum setup with autoexchange capability
19 | - Web-based admin interface
20 | - Built-in upgrade tools
21 | - Comprehensive screen management for monitoring
22 |
23 | ## Requirements
24 |
25 | - Fresh Ubuntu 18.04 or 20.04 installation
26 | - Minimum 8GB RAM
27 | - Clean domain or subdomain pointed to your VPS
28 |
29 | ## Quick Install
30 |
31 | ```bash
32 | curl https://raw.githubusercontent.com/afiniel/yiimp_install_script/master/install.sh | bash
33 | ```
34 |
35 | The installer will guide you through configuration options including:
36 | - Domain setup (main domain or subdomain)
37 | - SSL certificate installation
38 | - Database credentials
39 | - Admin portal location
40 | - Email settings
41 | - Stratum configuration
42 |
43 | ## Post-Install
44 |
45 | 1. After installation completes, a server reboot is **required**
46 | 2. Upon first login after reboot, wait 1-2 minutes for services to start
47 | 3. Use the `motd` command to view your pool status
48 | 4. Access your admin panel at the configured URL
49 |
50 | ## Directory Structure
51 |
52 | The installer uses a secure directory structure:
53 |
54 | | Directory | Purpose |
55 | |-----------|---------|
56 | | /home/crypto-data/yiimp | Main YiiMP directory |
57 | | /home/crypto-data/yiimp/site/web | Web files |
58 | | /home/crypto-data/yiimp/starts | Screen management scripts |
59 | | /home/crypto-data/yiimp/site/backup | Database backups |
60 | | /home/crypto-data/yiimp/site/configuration | Core configuration |
61 | | /home/crypto-data/yiimp/site/crons | Cron job scripts |
62 | | /home/crypto-data/yiimp/site/log | Log files |
63 | | /home/crypto-data/yiimp/site/stratum | Stratum server files |
64 |
65 | ## Usage Commands
66 |
67 | - View all screens: `screen -list`
68 | - Access specific screen: `screen -r main|loop2|blocks|debug`
69 | - Detach from screen: `ctrl+a+d`
70 | - Start/stop/restart services: `screens start|stop|restart main|loop2|blocks|debug`
71 | - Pool overview: `yiimp`
72 | - System status: `motd`
73 |
74 | ## DaemonBuilder
75 |
76 | Built-in coin daemon compiler accessible via the `daemonbuilder` command. Features:
77 | - Automated dependency handling
78 | - Support for multiple coins
79 | - Berkeley DB compilation
80 | - Custom port configuration
81 |
82 | ## Support
83 |
84 | For assistance:
85 | - Open an issue on GitHub
86 | - Join our Discord server
87 |
88 | Donations appreciated:
89 | - BTC: bc1qc4qqz8eu5j7u8pxfrfvv8nmcka7whhm225a3f9
90 | - ETH: 0xdA929d4f03e1009Fc031210DDE03bC40ea66D044
91 | - LTC: MC9xjhE7kmeBFMs4UmfAQyWuP99M49sCQp
92 | - DOGE: DHNhm8FqNAQ1VTNwmCHAp3wfQ6PcfzN1nu
93 | - SOLANA: 4Akj4XQXEKX4iPEd9A4ogXEPNrAsLm4wdATePz1XnyCu
94 | - BEP-20: 0xdA929d4f03e1009Fc031210DDE03bC40ea66D044
95 | - KASPA: kaspa:qrhfn2tl3ppc9qx448pgp6avv88gcav3dntw4p7h6v0ht3eac7pl6lkcjcy7r
96 |
97 | ## Security Notice
98 |
99 | Default permissions are configured for security - avoid modifying directory/file permissions as this may cause system instability.
100 |
--------------------------------------------------------------------------------
/RELEASE:
--------------------------------------------------------------------------------
1 | 0.4v Release 2022-08-01 @afiniel
2 |
3 |
4 | Update Readme.md
5 | -> Update the release date and version number.
6 | -> Rewrite most of the readme.md file.
7 |
8 | Database.
9 | -> Create function: database_import_sql
10 |
11 | Other.
12 | -> Edit end message.
13 | -> Remove old folder from the repo.
14 | -> Remove unused code.
15 | -> Code cleanup.
16 | -----------------------------------------------------------------
17 |
18 | 0.3v Release 2022-06-14 @afiniel
19 |
20 | Code clean up
21 | -> added missing php7.3-memcache php7.3-memcached
22 |
23 | SQL fixes.
24 | -> Now fully support solo mining.
25 | -> The script now import the missing block table
26 | -> the scrip also now import missing coins_thepool_life table
27 | -> Update SQL DUMP to: 2020-11-10-yaamp.sql.gz
28 |
29 |
30 | Serverconfig Update.
31 | -> Added solo fee
32 | -> Update sample cold wallet address.
33 |
34 |
35 | Other.
36 | -> Added figlet
37 | -> Terminal art fix on start and end
38 | -> The script now create a builder on HOME for upcoming.
--------------------------------------------------------------------------------
/daemon_builder/berkeley.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##################################################################################
4 | # This is the entry point for configuring the system. #
5 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox #
6 | # Updated by Afiniel for yiimpool use... #
7 | # #
8 | ##################################################################################
9 |
10 | BTCDEP="bc1q582gdvyp09038hp9n5sfdtp0plkx5x3yrhq05y"
11 | LTCDEP="ltc1qqw7cv4snx9ctmpcf25x26lphqluly4w6m073qw"
12 | ETHDEP="0x50C7d0BF9714dBEcDc1aa6Ab0E72af8e6Ce3b0aB"
13 | DOGEDEP="DSzcmyCRi7JeN4XUiV2qYhRQAydNv7A1Yb"
14 |
15 | sudo sed -i 's#btcdons#'$BTCDEP'#' conf/daemonbuilder.sh
16 | sleep 1
17 |
18 | sudo sed -i 's#ltcdons#'$LTCDEP'#' conf/daemonbuilder.sh
19 | sleep 1
20 |
21 | sudo sed -i 's#ethdons#'$ETHDEP'#' conf/daemonbuilder.sh
22 | sleep 1
23 |
24 | sudo sed -i 's#bchdons#'$DOGEDEP'#' conf/daemonbuilder.sh
25 | sleep 1
26 |
27 | sudo sed -i 's#daemonnameserver#'$daemonname'#' conf/daemonbuilder.sh
28 | sleep 1
29 |
30 | sudo sed -i 's#installpath#'$installtoserver'#' conf/daemonbuilder.sh
31 | sleep 1
32 |
33 | sudo sed -i 's#absolutepathserver#'$absolutepath'#' conf/daemonbuilder.sh
34 | sleep 1
35 |
36 | sudo sed -i 's#versiontag#'$TAG'#' conf/daemonbuilder.sh
37 | sleep 1
38 |
39 | sudo sed -i 's#distroserver#'$DISTRO'#' conf/daemonbuilder.sh
40 | sleep 1
41 |
42 | source /etc/yiimpoolversion.conf
43 | source /etc/functions.sh
44 | source /etc/yiimpool.conf
45 |
46 | # Set Stratum directory
47 | STRATUM_DIR="$STORAGE_ROOT/yiimp/site/stratum"
48 | # Set Function file.
49 | FUNCTIONFILE=daemonbuilder.sh
50 | # Set version tag
51 | TAG="$VERSION"
52 |
53 | sudo mkdir -p $STORAGE_ROOT/yiimp/yiimp_setup/tmp
54 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
55 | echo
56 | echo -e "$GREEN => Additional System Files Completed <= $COL_RESET"
57 |
58 | echo
59 | echo -e "$MAGENTA => Building Berkeley$GREEN 4.8$MAGENTA <= $COL_RESET"
60 | sudo mkdir -p $STORAGE_ROOT/berkeley/db4/
61 | hide_output sudo wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
62 | hide_output sudo tar -xzvf db-4.8.30.NC.tar.gz
63 | cd db-4.8.30.NC/build_unix/
64 | hide_output sudo ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$STORAGE_ROOT/berkeley/db4/
65 | hide_output sudo make -j$((`nproc`+1))
66 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
67 | sudo rm -r db-4.8.30.NC.tar.gz db-4.8.30.NC
68 | echo
69 | echo -e "$GREEN => Berkeley 4.8 Completed <= $COL_RESET"
70 | echo
71 |
72 | echo -e "$MAGENTA => Building Berkeley$GREEN 5.1$MAGENTA <= $COL_RESET"
73 | echo
74 | sudo mkdir -p $STORAGE_ROOT/berkeley/db5/
75 | hide_output sudo wget 'http://download.oracle.com/berkeley-db/db-5.1.29.tar.gz'
76 | hide_output sudo tar -xzvf db-5.1.29.tar.gz
77 | cd db-5.1.29/build_unix/
78 | hide_output sudo ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$STORAGE_ROOT/berkeley/db5/
79 | hide_output sudo make -j$((`nproc`+1))
80 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
81 | sudo rm -r db-5.1.29.tar.gz db-5.1.29
82 | echo -e "$GREEN => Berkeley 5.1 Completed <= $COL_RESET"
83 | echo
84 | echo -e "$MAGENTA => Building Berkeley$GREEN 5.3$MAGENTA <= $COL_RESET"
85 | echo
86 | sudo mkdir -p $STORAGE_ROOT/berkeley/db5.3/
87 | hide_output sudo wget 'http://anduin.linuxfromscratch.org/BLFS/bdb/db-5.3.28.tar.gz'
88 | hide_output sudo tar -xzvf db-5.3.28.tar.gz
89 | cd db-5.3.28/build_unix/
90 | hide_output sudo ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$STORAGE_ROOT/berkeley/db5.3/
91 | hide_output sudo make -j$((`nproc`+1))
92 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
93 | sudo rm -r db-5.3.28.tar.gz db-5.3.28
94 | echo -e "$GREEN => Berkeley 5.3 Completed <= $COL_RESET"
95 | echo
96 | echo -e "$MAGENTA => Building Berkeley$GREEN 6.2$MAGENTA <= $COL_RESET"
97 | echo
98 | sudo mkdir -p $STORAGE_ROOT/berkeley/db6.2/
99 | hide_output sudo wget 'https://download.oracle.com/berkeley-db/db-6.2.23.tar.gz'
100 | hide_output sudo tar -xzvf db-6.2.23.tar.gz
101 | cd db-6.2.23/build_unix/
102 | hide_output sudo ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$STORAGE_ROOT/berkeley/db6.2/
103 | hide_output sudo make -j$((`nproc`+1))
104 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
105 | sudo rm -r db-6.2.23.tar.gz db-6.2.23
106 | echo -e "$GREEN => Berkeley 6.2 Completed <= $COL_RESET"
107 | echo
108 | echo -e "$MAGENTA => Building Berkeley$GREEN 18$MAGENTA <= $COL_RESET"
109 | echo
110 | sudo mkdir -p $STORAGE_ROOT/berkeley/db18/
111 | hide_output sudo wget 'https://download.oracle.com/berkeley-db/db-18.1.40.tar.gz'
112 | hide_output sudo tar -xzvf db-18.1.40.tar.gz
113 | cd db-18.1.40/build_unix/
114 | hide_output sudo ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$STORAGE_ROOT/berkeley/db18/
115 | hide_output sudo make -j$((`nproc`+1))
116 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
117 | sudo rm -r db-18.1.40.tar.gz db-18.1.40
118 | echo -e "$GREEN => Berkeley 18 Completed <= $COL_RESET"
119 | echo
120 | echo -e "$MAGENTA => Building OpenSSL$GREEN 1.0.2g$MAGENTA <= $COL_RESET"
121 | echo
122 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
123 | hide_output sudo wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2g.tar.gz --no-check-certificate
124 | hide_output sudo tar -xf openssl-1.0.2g.tar.gz
125 | cd openssl-1.0.2g
126 | hide_output sudo ./config --prefix=$STORAGE_ROOT/openssl --openssldir=$STORAGE_ROOT/openssl shared zlib
127 | hide_output sudo make -j$((`nproc`+1))
128 | hide_output sudo make install -j$((`nproc`+1))
129 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
130 | sudo rm -r openssl-1.0.2g.tar.gz openssl-1.0.2g
131 | echo -e "$GREEN =>OpenSSL 1.0.2g Completed <= $COL_RESET"
132 | echo
133 |
134 | echo -e "$MAGENTA => Building bls-signatures$GREEN <= $COL_RESET"
135 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
136 | hide_output sudo wget 'https://github.com/codablock/bls-signatures/archive/v20181101.zip'
137 | hide_output sudo unzip v20181101.zip
138 | cd bls-signatures-20181101
139 | hide_output sudo cmake .
140 | hide_output sudo make install -j$((`nproc`+1))
141 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
142 | sudo rm -r v20181101.zip bls-signatures-20181101
143 | echo
144 | echo -e "$GREEN => bls-signatures Completed$COL_RESET"
145 |
146 | echo
147 | echo
148 | echo -e "$YELLOW => Building$GREEN blocknotify.sh$YELLOW <= $COL_RESET"
149 | if [[ ("$wireguard" == "true") ]]; then
150 | source $STORAGE_ROOT/yiimp/.wireguard.conf
151 | echo '#####################################
152 | # Created by Afiniel for Yiimpool use... #
153 | ###########################################
154 | #!/bin/bash
155 | blocknotify '""''"${DBInternalIP}"''""':$1 $2 $3' | sudo -E tee /usr/bin/blocknotify.sh >/dev/null 2>&1
156 | sudo chmod +x /usr/bin/blocknotify.sh
157 | else
158 | echo '#####################################
159 | # Created by Afiniel for Yiimpool use... #
160 | ###########################################
161 | #!/bin/bash
162 | blocknotify 127.0.0.1:$1 $2 $3' | sudo -E tee /usr/bin/blocknotify.sh >/dev/null 2>&1
163 | sudo chmod +x /usr/bin/blocknotify.sh
164 | fi
165 |
166 |
167 | echo
168 | echo -e "$GREEN Daemon setup completed$COL_RESET"
169 |
170 | set +eu +o pipefail
171 | cd $HOME/yiimp_install_script/yiimp_single
172 |
173 | echo -e "$MAGENTA => Installing daemonbuilder <=$COL_RESET"
174 | cd $HOME/yiimp_install_script/daemon_builder
175 | sudo mkdir -p conf
176 | sudo cp -r $HOME/yiimp_install_script/daemon_builder/utils/* $STORAGE_ROOT/daemon_builder
177 |
178 | sudo cp -r $HOME/yiimp_install_script/daemon_builder/conf/daemonbuilder.sh /etc/
179 |
180 | # Copy addport to /usr/bin
181 | hide_output sudo cp -r $HOME/yiimp_install_script/daemon_builder/utils/addport.sh /usr/bin/addport
182 | hide_output sudo chmod +x /usr/bin/addport
183 |
184 |
185 | source /etc/daemonbuilder.sh
186 |
187 |
188 | # Enable DaemonBuilder command.
189 | echo '
190 | #!/usr/bin/env bash
191 | source /etc/yiimpool.conf
192 | source /etc/functions.sh
193 | cd $STORAGE_ROOT/daemon_builder
194 | bash start.sh
195 | cd ~
196 | ' | sudo -E tee /usr/bin/daemonbuilder >/dev/null 2>&1
197 |
198 | # Set permissions
199 | sudo chmod +x /usr/bin/daemonbuilder
200 | echo -e "$GREEN Complete...$COL_RESET"
201 |
202 | #Check if conf directory exists
203 | if [ ! -d "$STORAGE_ROOT/daemon_builder/conf" ]; then
204 | sudo mkdir -p $STORAGE_ROOT/daemon_builder/conf
205 | fi
206 |
207 | # TODO: Fix the $TAG
208 | echo '#!/bin/sh
209 | USERSERVER='"${whoami}"'
210 | PATH_STRATUM='"${STRATUM_DIR}"'
211 | FUNCTION_FILE='"${FUNCTIONFILE}"'
212 | VERSION='"${TAG}"'
213 | BTCDEP='"${BTCDEP}"'
214 | LTCDEP='"${LTCDEP}"'
215 | ETHDEP='"${ETHDEP}"'
216 | DOGEDEP='"${DOGEDEP}"''| sudo -E tee $STORAGE_ROOT/daemon_builder/conf/info.sh >/dev/null 2>&1
217 | hide_output sudo chmod +x $STORAGE_ROOT/daemon_builder/conf/info.sh
218 |
219 |
220 | cd $HOME/yiimp_install_script/yiimp_single
--------------------------------------------------------------------------------
/daemon_builder/conf/daemonbuilder.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ##################################################################
3 | # Current Modified by Afiniel for Daemon coin & addport & stratum
4 | ##################################################################
5 | source /etc/functions.sh
6 | source /etc/yiimpool.conf
7 | source $STORAGE_ROOT/yiimp/.yiimp.conf
8 |
9 | absolutepath=absolutepathserver
10 | installtoserver=installpath
11 | daemonname=daemonnameserver
12 | path_stratum=$STORAGE_ROOT/yiimp/site/stratum
13 |
14 | ESC_SEQ="\x1b["
15 | COL_RESET=$ESC_SEQ"39;49;00m"
16 | RED=$ESC_SEQ"31;01m"
17 | GREEN=$ESC_SEQ"32;01m"
18 | YELLOW=$ESC_SEQ"33;01m"
19 | BLUE=$ESC_SEQ"34;01m"
20 | MAGENTA=$ESC_SEQ"35;01m"
21 | CYAN=$ESC_SEQ"36;01m"
22 |
23 | function spinner {
24 | local pid=$!
25 | local delay=0.35
26 | local spinstr='|/-\'
27 | while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
28 | local temp=${spinstr#?}
29 | printf " [%c] " "$spinstr"
30 | local spinstr=$temp${spinstr%"$temp"}
31 | sleep $delay
32 | printf "\b\b\b\b\b\b"
33 | done
34 | printf " \b\b\b\b"
35 | }
36 |
37 | function spinning_timer() {
38 | animation=( ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ )
39 | end=$((SECONDS+NUM))
40 | while [ $SECONDS -lt $end ]; do
41 | for i in "${animation[@]}"; do
42 | echo -ne "${RED}\r$i ${CYAN}${MSG1}${NC}"
43 | sleep 0.1
44 | done
45 | done
46 | echo -e "${MSG2}"
47 | }
48 |
49 | # terminal art end screen.
50 |
51 | function install_end_message {
52 |
53 | clear
54 | echo
55 | clear
56 | echo
57 | figlet -f slant -w 100 "Complete!"
58 | echo -e "$CYAN --------------------------------------------------------------------------- $COL_RESET"
59 | echo -e "$YELLOW Script install of Daemon & Addpor & Stratum By Afiniel $COL_RESET"
60 | echo -e "$GREEN Donations are welcome at wallets below: $COL_RESET"
61 | echo -e "$YELLOW BTC:$COL_RESET $MAGENTA btcdons $COL_RESET"
62 | echo -e "$YELLOW LTC:$COL_RESET $MAGENTA ltcdons $COL_RESET"
63 | echo -e "$YELLOW ETH:$COL_RESET $MAGENTA ethdons $COL_RESET"
64 | echo -e "$YELLOW BCH:$COL_RESET $MAGENTA bchdons $COL_RESET"
65 | echo -e "$CYAN --------------------------------------------------------------------------- $COL_RESET"
66 | echo -e "$CYAN https://github.com/Afiniel/yiimp_install_script $COL_RESET"
67 | echo -e "$CYAN --------------------------------------------------------------------------- $COL_RESET"
68 | echo
69 | echo -e "$CYAN --------------------------------------------------------------------------- $COL_RESET"
70 | echo -e "$RED How to use $COL_RESET"
71 | echo -e "$GREEN To build a new coin :$COL_RESET $MAGENTA ${daemonname} $COL_RESET"
72 | echo -e "$GREEN To added stratum to coin and dedicated port : $COL_RESET $MAGENTA addport $COL_RESET"
73 | echo -e "$CYAN --------------------------------------------------------------------------- $COL_RESET"
74 | echo
75 | cd ~
76 | }
77 |
78 | # terminal art start screen.
79 | function term_art {
80 |
81 | echo
82 | echo -e "$CYAN----------------------------------------------------------------------------------------- $COL_RESET"
83 | echo " "
84 | echo " ██████╗ █████╗ ███████╗███╗ ███╗ ██████╗ ███╗ ██╗ ██████╗ ██████╗ ██╗███╗ ██╗"
85 | echo " ██╔══██╗██╔══██╗██╔════╝████╗ ████║██╔═══██╗████╗ ██║ ██╔════╝██╔═══██╗██║████╗ ██║"
86 | echo " ██║ ██║███████║█████╗ ██╔████╔██║██║ ██║██╔██╗ ██║ ██║ ██║ ██║██║██╔██╗ ██║"
87 | echo " ██║ ██║██╔══██║██╔══╝ ██║╚██╔╝██║██║ ██║██║╚██╗██║ ██║ ██║ ██║██║██║╚██╗██║"
88 | echo " ██████╔╝██║ ██║███████╗██║ ╚═╝ ██║╚██████╔╝██║ ╚████║ ╚██████╗╚██████╔╝██║██║ ╚████║"
89 | echo " ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝"
90 | echo -e "$GREEN *Daemon Coin Installer$COL_RESET $MAGENTA versiontag $COL_RESET"
91 | echo -e "$CYAN----------------------------------------------------------------------------------------- $COL_RESET"
92 | echo
93 | }
94 |
95 | function hide_output {
96 | if [[ "${DISTRO}" == '22' ]]; then
97 | OUTPUT=$(tempfile)
98 | else
99 | OUTPUT=$(tempfile)
100 | fi
101 | OUTPUT=$(tempfile)
102 | $@ &> $OUTPUT & spinner
103 | E=$?
104 | if [ $E != 0 ]; then
105 | echo
106 | echo FAILED: $@
107 | echo -----------------------------------------
108 | cat $OUTPUT
109 | echo -----------------------------------------
110 | exit $E
111 | fi
112 |
113 | rm -f $OUTPUT
114 | }
115 |
116 | function spinner_output {
117 | OUTPUT=$(tempfile)
118 | $@ &> $OUTPUT & spinning_timer
119 | E=$?
120 | if [ $E != 0 ]; then
121 | echo
122 | echo FAILED: $@
123 | echo -----------------------------------------
124 | cat $OUTPUT
125 | echo -----------------------------------------
126 | exit $E
127 | fi
128 |
129 | rm -f $OUTPUT
130 | }
131 |
132 | function apt_get_quiet {
133 | DEBIAN_FRONTEND=noninteractive hide_output sudo apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" "$@"
134 | }
135 |
136 | function apt_install {
137 | PACKAGES=$@
138 | apt_get_quiet install $PACKAGES
139 | }
140 |
141 | function ufw_allow {
142 | if [ -z "$DISABLE_FIREWALL" ]; then
143 | sudo ufw allow $1 > /dev/null;
144 | fi
145 | }
146 |
147 | function restart_service {
148 | hide_output sudo service $1 restart
149 | }
150 |
151 | ## Dialog Functions ##
152 | function message_box {
153 | dialog --title "$1" --msgbox "$2" 0 0
154 | }
155 |
156 | function input_box {
157 | # input_box "title" "prompt" "defaultvalue" VARIABLE
158 | # The user's input will be stored in the variable VARIABLE.
159 | # The exit code from dialog will be stored in VARIABLE_EXITCODE.
160 | declare -n result=$4
161 | declare -n result_code=$4_EXITCODE
162 | result=$(dialog --stdout --title "$1" --inputbox "$2" 0 0 "$3")
163 | result_code=$?
164 | }
165 |
166 | function input_menu {
167 | # input_menu "title" "prompt" "tag item tag item" VARIABLE
168 | # The user's input will be stored in the variable VARIABLE.
169 | # The exit code from dialog will be stored in VARIABLE_EXITCODE.
170 | declare -n result=$4
171 | declare -n result_code=$4_EXITCODE
172 | local IFS=^$'\n'
173 | result=$(dialog --stdout --title "$1" --menu "$2" 0 0 0 $3)
174 | result_code=$?
175 | }
176 |
177 | function get_publicip_from_web_service {
178 | # This seems to be the most reliable way to determine the
179 | # machine's public IP address: asking a very nice web API
180 | # for how they see us. Thanks go out to icanhazip.com.
181 | # See: https://major.io/icanhazip-com-faq/
182 | #
183 | # Pass '4' or '6' as an argument to this function to specify
184 | # what type of address to get (IPv4, IPv6).
185 | curl -$1 --fail --silent --max-time 15 icanhazip.com 2>/dev/null
186 | }
187 |
188 | function get_default_privateip {
189 | # Return the IP address of the network interface connected
190 | # to the Internet.
191 | #
192 | # Pass '4' or '6' as an argument to this function to specify
193 | # what type of address to get (IPv4, IPv6).
194 | #
195 | # We used to use `hostname -I` and then filter for either
196 | # IPv4 or IPv6 addresses. However if there are multiple
197 | # network interfaces on the machine, not all may be for
198 | # reaching the Internet.
199 | #
200 | # Instead use `ip route get` which asks the kernel to use
201 | # the system's routes to select which interface would be
202 | # used to reach a public address. We'll use 8.8.8.8 as
203 | # the destination. It happens to be Google Public DNS, but
204 | # no connection is made. We're just seeing how the box
205 | # would connect to it. There many be multiple IP addresses
206 | # assigned to an interface. `ip route get` reports the
207 | # preferred. That's good enough for us. See issue #121.
208 | #
209 | # With IPv6, the best route may be via an interface that
210 | # only has a link-local address (fe80::*). These addresses
211 | # are only unique to an interface and so need an explicit
212 | # interface specification in order to use them with bind().
213 | # In these cases, we append "%interface" to the address.
214 | # See the Notes section in the man page for getaddrinfo and
215 | # https://discourse.mailinabox.email/t/update-broke-mailinabox/34/9.
216 | #
217 | # Also see ae67409603c49b7fa73c227449264ddd10aae6a9 and
218 | # issue #3 for why/how we originally added IPv6.
219 |
220 | target=8.8.8.8
221 |
222 | # For the IPv6 route, use the corresponding IPv6 address
223 | # of Google Public DNS. Again, it doesn't matter so long
224 | # as it's an address on the public Internet.
225 | if [ "$1" == "6" ]; then target=2001:4860:4860::8888; fi
226 |
227 | # Get the route information.
228 | route=$(ip -$1 -o route get $target | grep -v unreachable)
229 |
230 | # Parse the address out of the route information.
231 | address=$(echo $route | sed "s/.* src \([^ ]*\).*/\1/")
232 |
233 | if [[ "$1" == "6" && $address == fe80:* ]]; then
234 | # For IPv6 link-local addresses, parse the interface out
235 | # of the route information and append it with a '%'.
236 | interface=$(echo $route | sed "s/.* dev \([^ ]*\).*/\1/")
237 | address=$address%$interface
238 | fi
239 |
240 | echo $address
241 |
242 | }
243 |
--------------------------------------------------------------------------------
/daemon_builder/conf/editconf.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | #
3 | # This is a helper tool for editing configuration files during the setup
4 | # process. The tool is given new values for settings as command-line
5 | # arguments. It comments-out existing setting values in the configuration
6 | # file and adds new values either after their former location or at the
7 | # end.
8 | #
9 | # The configuration file has settings that look like:
10 | #
11 | # NAME=VALUE
12 | #
13 | # If the -s option is given, then space becomes the delimiter, i.e.:
14 | #
15 | # NAME VALUE
16 | #
17 | # If the -c option is given, then the supplied character becomes the comment character
18 | #
19 | # If the -w option is given, then setting lines continue onto following
20 | # lines while the lines start with whitespace, e.g.:
21 | #
22 | # NAME VAL
23 | # UE
24 |
25 | import sys, re
26 |
27 | # sanity check
28 | if len(sys.argv) < 3:
29 | print("usage: python3 editconf.py /etc/file.conf [-s] [-w] [-c ] [-t] NAME=VAL [NAME=VAL ...]")
30 | sys.exit(1)
31 |
32 | # parse command line arguments
33 | filename = sys.argv[1]
34 | settings = sys.argv[2:]
35 |
36 | delimiter = "="
37 | delimiter_re = r"\s*=\s*"
38 | comment_char = "#"
39 | folded_lines = False
40 | testing = False
41 | while settings[0][0] == "-" and settings[0] != "--":
42 | opt = settings.pop(0)
43 | if opt == "-s":
44 | # Space is the delimiter
45 | delimiter = " "
46 | delimiter_re = r"\s+"
47 | elif opt == "-w":
48 | # Line folding is possible in this file.
49 | folded_lines = True
50 | elif opt == "-c":
51 | # Specifies a different comment character.
52 | comment_char = settings.pop(0)
53 | elif opt == "-t":
54 | testing = True
55 | else:
56 | print("Invalid option.")
57 | sys.exit(1)
58 |
59 | # sanity check command line
60 | for setting in settings:
61 | try:
62 | name, value = setting.split("=", 1)
63 | except:
64 | import subprocess
65 | print("Invalid command line: ", subprocess.list2cmdline(sys.argv))
66 |
67 | # create the new config file in memory
68 |
69 | found = set()
70 | buf = ""
71 | input_lines = list(open(filename))
72 |
73 | while len(input_lines) > 0:
74 | line = input_lines.pop(0)
75 |
76 | # If this configuration file uses folded lines, append any folded lines
77 | # into our input buffer.
78 | if folded_lines and line[0] not in (comment_char, " ", ""):
79 | while len(input_lines) > 0 and input_lines[0][0] in " \t":
80 | line += input_lines.pop(0)
81 |
82 | # See if this line is for any settings passed on the command line.
83 | for i in range(len(settings)):
84 | # Check that this line contain this setting from the command-line arguments.
85 | name, val = settings[i].split("=", 1)
86 | m = re.match(
87 | "(\s*)"
88 | + "(" + re.escape(comment_char) + "\s*)?"
89 | + re.escape(name) + delimiter_re + "(.*?)\s*$",
90 | line, re.S)
91 | if not m: continue
92 | indent, is_comment, existing_val = m.groups()
93 |
94 | # If this is already the setting, do nothing.
95 | if is_comment is None and existing_val == val:
96 | # It may be that we've already inserted this setting higher
97 | # in the file so check for that first.
98 | if i in found: break
99 | buf += line
100 | found.add(i)
101 | break
102 |
103 | # comment-out the existing line (also comment any folded lines)
104 | if is_comment is None:
105 | buf += comment_char + line.rstrip().replace("\n", "\n" + comment_char) + "\n"
106 | else:
107 | # the line is already commented, pass it through
108 | buf += line
109 |
110 | # if this option oddly appears more than once, don't add the setting again
111 | if i in found:
112 | break
113 |
114 | # add the new setting
115 | buf += indent + name + delimiter + val + "\n"
116 |
117 | # note that we've applied this option
118 | found.add(i)
119 |
120 | break
121 | else:
122 | # If did not match any setting names, pass this line through.
123 | buf += line
124 |
125 | # Put any settings we didn't see at the end of the file.
126 | for i in range(len(settings)):
127 | if i not in found:
128 | name, val = settings[i].split("=", 1)
129 | buf += name + delimiter + val + "\n"
130 |
131 | if not testing:
132 | # Write out the new file.
133 | with open(filename, "w") as f:
134 | f.write(buf)
135 | else:
136 | # Just print the new file to stdout.
137 | print(buf)
138 |
--------------------------------------------------------------------------------
/daemon_builder/conf/getip.sh:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Updated by Afiniel for crypto use...
3 | #####################################################
4 |
5 | FUNC=/etc/daemonbuilder.sh
6 | MULTISERVER=/etc/multiserver.sh
7 | if [[ -f "$MULTISERVER" ]]; then
8 | source /etc/multiserver.sh
9 | elif [[ -f "$FUNC" ]]; then
10 | source /etc/daemonbuilder.sh
11 | fi
12 |
13 | echo -e "$CYAN => Setting our global variables : $COL_RESET"
14 |
15 | # If the machine is behind a NAT, inside a VM, etc., it may not know
16 | # its IP address on the public network / the Internet. Ask the Internet
17 | # and possibly confirm with user.
18 | if [ -z "${PUBLIC_IP:-}" ]; then
19 | # Ask the Internet.
20 | GUESSED_IP=$(get_publicip_from_web_service 4)
21 |
22 | # On the first run, if we got an answer from the Internet then don't
23 | # ask the user.
24 | if [[ -z "${DEFAULT_PUBLIC_IP:-}" && ! -z "$GUESSED_IP" ]]; then
25 | PUBLIC_IP=$GUESSED_IP
26 |
27 | # On later runs, if the previous value matches the guessed value then
28 | # don't ask the user either.
29 | elif [ "${DEFAULT_PUBLIC_IP:-}" == "$GUESSED_IP" ]; then
30 | PUBLIC_IP=$GUESSED_IP
31 | fi
32 |
33 | if [ -z "${PUBLIC_IP:-}" ]; then
34 | input_box "Public IP Address" \
35 | "Enter the public IP address of this machine, as given to you by your ISP.
36 | \n\nPublic IP address:" \
37 | "$DEFAULT_PUBLIC_IP" \
38 | PUBLIC_IP
39 |
40 | if [ -z "$PUBLIC_IP" ]; then
41 | # user hit ESC/cancel
42 | exit
43 | fi
44 | fi
45 | fi
46 |
47 | # Same for IPv6. But it's optional. Also, if it looks like the system
48 | # doesn't have an IPv6, don't ask for one.
49 | if [ -z "${PUBLIC_IPV6:-}" ]; then
50 | # Ask the Internet.
51 | GUESSED_IP=$(get_publicip_from_web_service 6)
52 | MATCHED=0
53 | if [[ -z "${DEFAULT_PUBLIC_IPV6:-}" && ! -z "$GUESSED_IP" ]]; then
54 | PUBLIC_IPV6=$GUESSED_IP
55 | elif [[ "${DEFAULT_PUBLIC_IPV6:-}" == "$GUESSED_IP" ]]; then
56 | # No IPv6 entered and machine seems to have none, or what
57 | # the user entered matches what the Internet tells us.
58 | PUBLIC_IPV6=$GUESSED_IP
59 | MATCHED=1
60 | elif [[ -z "${DEFAULT_PUBLIC_IPV6:-}" ]]; then
61 | DEFAULT_PUBLIC_IP=$(get_default_privateip 6)
62 | fi
63 |
64 | if [[ -z "${PUBLIC_IPV6:-}" && $MATCHED == 0 ]]; then
65 | input_box "IPv6 Address (Optional)" \
66 | "Enter the public IPv6 address of this machine, as given to you by your ISP.
67 | \n\nLeave blank if the machine does not have an IPv6 address.
68 | \n\nPublic IPv6 address:" \
69 | ${DEFAULT_PUBLIC_IPV6:-} \
70 | PUBLIC_IPV6
71 |
72 | if [ ! $PUBLIC_IPV6_EXITCODE ]; then
73 | # user hit ESC/cancel
74 | exit
75 | fi
76 | fi
77 | fi
78 |
79 | # Get the IP addresses of the local network interface(s) that are connected
80 | # to the Internet. We need these when we want to have services bind only to
81 | # the public network interfaces (not loopback, not tunnel interfaces).
82 | # if [ -z "$PRIVATE_IP" ]; then
83 | # DEFAULT_PRIVATE_IP=$(get_default_privateip 4)
84 | # input_box "Private IP Address (Optional)" \
85 | # "Enter the private IP address of this machine, as given to you by your ISP.
86 | # \n\nLeave as your public IP if the machine does not have a private IP address.
87 | # \n\nPrivate IP address:" \
88 | # $DEFAULT_PRIVATE_IP \
89 | # PRIVATE_IP
90 | #
91 | # if [ -z "$PRIVATE_IP" ]; then
92 | # user hit ESC/cancel
93 | # exit
94 | # fi
95 | # fi
96 |
97 | # Automatic configuration, e.g. as used in our Vagrant configuration.
98 | if [ "$PUBLIC_IP" = "auto" ]; then
99 | # Use a public API to get our public IP address, or fall back to local network configuration.
100 | PUBLIC_IP=$(get_publicip_from_web_service 4 || get_default_privateip 4)
101 | fi
102 | if [ "$PUBLIC_IPV6" = "auto" ]; then
103 | # Use a public API to get our public IPv6 address, or fall back to local network configuration.
104 | PUBLIC_IPV6=$(get_publicip_from_web_service 6 || get_default_privateip 6)
105 | fi
106 |
--------------------------------------------------------------------------------
/daemon_builder/conf/preflight.sh:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox
3 | # Updated by Afiniel
4 | #####################################################
5 |
6 | if [ "`lsb_release -d | sed 's/.*:\s*//' | sed 's/18\.04\.[0-9]/18.04/' `" == "Ubuntu 18.04 LTS" ]; then
7 | DISTRO=18
8 | sudo chmod g-w /etc /etc/default /usr
9 | else [ "`lsb_release -d | sed 's/.*:\s*//' | sed 's/16\.04\.[0-9]/16.04/' `" != "Ubuntu 16.04 LTS" ];
10 | DISTRO=16
11 | fi
12 |
13 | TOTAL_PHYSICAL_MEM=$(head -n 1 /proc/meminfo | awk '{print $2}')
14 | if [ $TOTAL_PHYSICAL_MEM -lt 1436000 ]; then
15 | if [ ! -d /vagrant ]; then
16 | TOTAL_PHYSICAL_MEM=$(expr \( \( $TOTAL_PHYSICAL_MEM \* 1024 \) / 1000 \) / 1000)
17 | echo "Your Pool Server needs more memory (RAM) to function properly."
18 | echo "Please provision a machine with at least 1536 GB, 6 GB recommended."
19 | echo "This machine has $TOTAL_PHYSICAL_MEM MB memory."
20 | exit
21 | fi
22 | fi
23 |
24 | if [ $TOTAL_PHYSICAL_MEM -lt 1436000 ]; then
25 | echo "WARNING: Your Pool Server has less than 1.5 GB of memory."
26 | echo " It might run unreliably when under heavy load."
27 | fi
28 |
29 | # Check swap
30 | echo Checking if swap space is needed and if so creating...
31 |
32 | SWAP_MOUNTED=$(cat /proc/swaps | tail -n+2)
33 | SWAP_IN_FSTAB=$(grep "swap" /etc/fstab)
34 | ROOT_IS_BTRFS=$(grep "\/ .*btrfs" /proc/mounts)
35 | TOTAL_PHYSICAL_MEM=$(head -n 1 /proc/meminfo | awk '{print $2}')
36 | AVAILABLE_DISK_SPACE=$(df / --output=avail | tail -n 1)
37 | if
38 | [ -z "$SWAP_MOUNTED" ] &&
39 | [ -z "$SWAP_IN_FSTAB" ] &&
40 | [ ! -e /swapfile ] &&
41 | [ -z "$ROOT_IS_BTRFS" ] &&
42 | [ $TOTAL_PHYSICAL_MEM -lt 1536000 ] &&
43 | [ $AVAILABLE_DISK_SPACE -gt 5242880 ]
44 | then
45 | echo "Adding a swap file to the system..."
46 |
47 | # Allocate and activate the swap file. Allocate in 1KB chuncks
48 | # doing it in one go, could fail on low memory systems
49 | sudo fallocate -l 3G /swapfile
50 | if [ -e /swapfile ]; then
51 | sudo chmod 600 /swapfile
52 | hide_output sudo mkswap /swapfile
53 | sudo swapon /swapfile
54 | echo "vm.swappiness=10" >> sudo /etc/sysctl.conf
55 | fi
56 | # Check if swap is mounted then activate on boot
57 | if swapon -s | grep -q "\/swapfile"; then
58 | echo "/swapfile none swap sw 0 0" >> sudo /etc/fstab
59 | else
60 | echo "ERROR: Swap allocation failed!"
61 | fi
62 | fi
63 |
64 | ARCHITECTURE=$(uname -m)
65 | if [ "$ARCHITECTURE" != "x86_64" ]; then
66 | if [ -z "$ARM" ]; then
67 | echo "${namescryptinstall} ${TAG} only supports x86_64 and will not work on any other architecture, like ARM or 32 bit OS."
68 | echo "Your architecture is $ARCHITECTURE"
69 | exit
70 | fi
71 | fi
72 |
73 | # Set STORAGE_USER and STORAGE_ROOT to default values (utils and /home/utils), unless
74 | # we've already got those values from a previous run.
75 | #if [ -z "$STORAGE_USER" ]; then
76 | # STORAGE_USER=$([[ -z "$DEFAULT_STORAGE_USER" ]] && echo "utils" || echo "$DEFAULT_STORAGE_USER")
77 | #fi
78 | #if [ -z "$STORAGE_ROOT" ]; then
79 | # STORAGE_ROOT=$([[ -z "$DEFAULT_STORAGE_ROOT" ]] && echo "/home/$STORAGE_USER" || echo "$DEFAULT_STORAGE_ROOT")
80 | #fi
--------------------------------------------------------------------------------
/daemon_builder/conf/prerequisite.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ##########################################
3 | # Updated by Afiniel for crypto use...
4 | ##########################################
5 |
6 | ESC_SEQ="\x1b["
7 | COL_RESET=$ESC_SEQ"39;49;00m"
8 | RED=$ESC_SEQ"31;01m"
9 | GREEN=$ESC_SEQ"32;01m"
10 | YELLOW=$ESC_SEQ"33;01m"
11 | BLUE=$ESC_SEQ"34;01m"
12 | MAGENTA=$ESC_SEQ"35;01m"
13 | CYAN=$ESC_SEQ"36;01m"
14 |
15 | echo
16 | echo
17 | echo -e "$CYAN => Check prerequisite : $COL_RESET"
18 |
19 | if [ "`lsb_release -d | sed 's/.*:\s*//' | sed 's/18\.04\.[0-9]/18.04/' `" == "Ubuntu 18.04 LTS" ]; then
20 | DISTRO=18
21 | sudo chmod g-w /etc /etc/default /usr
22 | elif [ "`lsb_release -d | sed 's/.*:\s*//' | sed 's/16\.04\.[0-9]/16.04/' `" == "Ubuntu 16.04 LTS" ]; then
23 | DISTRO=16
24 | echo -e "$RED This Script not supports on distro ${DISTRO} This run on Ubuntu 18.04 LTS and Ubuntu 20.04 LTS $COL_RESET"
25 | echo -e "$RED Stop installation now! $COL_RESET"
26 | exit
27 | elif [ "`lsb_release -d | sed 's/.*:\s*//' | sed 's/20\.04\.[0-9]/20.04/' `" == "Ubuntu 20.04 LTS" ]; then
28 | DISTRO=20
29 | sudo chmod g-w /etc /etc/default /usr
30 | elif [ "`lsb_release -d | sed 's/.*:\s*//' | sed 's/22\.04\.[0-9]/22.04/' `" == "Ubuntu 22.04 LTS" ]; then
31 | DISTRO=22
32 | echo -e "$RED This Script not supports on distro ${DISTRO} This run on Ubuntu 18.04 LTS and Ubuntu 20.04 LTS $COL_RESET"
33 | echo -e "$RED Stop installation now! $COL_RESET"
34 | exit
35 | #sudo chmod g-w /etc /etc/default /usr
36 | fi
37 |
38 |
39 | ARCHITECTURE=$(uname -m)
40 | if [ "$ARCHITECTURE" != "x86_64" ]; then
41 | if [ -z "$ARM" ]; then
42 | echo -e "$REDYiimP Install Script only supports x86_64 and will not work on any other architecture, like ARM or 32 bit OS. $COL_RESET"
43 | echo -e "$REDYour architecture is $ARCHITECTURE $COL_RESET"
44 | exit
45 | fi
46 | fi
47 |
--------------------------------------------------------------------------------
/daemon_builder/requirements.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | #
4 | # Author: Afiniel
5 | # Date: 2023-01-12
6 | #
7 | # Description: This install all requirements for DaemonBuilder.
8 | #
9 |
10 | # Load functions
11 | source /etc/functions.sh
12 | source /etc/yiimpool.conf
13 | source $STORAGE_ROOT/yiimp/.yiimp.conf
14 |
15 | set -eu -o pipefail
16 |
17 | function print_error {
18 | read line file <<<$(caller)
19 | echo "An error occurred in line $line of file $file:" >&2
20 | sed "${line}q;d" "$file" >&2
21 | }
22 | trap print_error ERR
23 |
24 | cd $HOME/yiimp_install_script/daemon_builder
25 | hide_output sudo cp -r $HOME/yiimp_install_script/daemon_builder/utils/screen-scrypt-daemonbuilder.sh /etc/
26 | hide_output sudo chmod +x /etc/screen-scrypt-daemonbuilder.sh
27 |
28 | #Install dependencies
29 | echo
30 | echo -e "$MAGENTA => Installing Package to compile crypto currency <= $COL_RESET"
31 | hide_output sudo apt-get update
32 | hide_output sudo apt-get -y upgrade
33 | hide_output sudo apt-get -y install p7zip-full
34 | apt_install build-essential libzmq5 libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils cmake libboost-all-dev zlib1g-dev \
35 | libseccomp-dev libcap-dev libminiupnpc-dev gettext libcanberra-gtk-module libqrencode-dev libzmq3-dev \
36 | libqt5gui5 libqt5core5a libqt5webkit5-dev libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
37 |
38 | if [[ ("${DISTRO}" == "18") ]]; then
39 | apt_install libz-dev libminiupnpc10
40 | hide_output sudo add-apt-repository -y ppa:bitcoin/bitcoin
41 | hide_output sudo apt-get update
42 | hide_output sudo apt-get -y upgrade
43 | apt_install libdb4.8-dev libdb4.8++-dev libdb5.3 libdb5.3++
44 | fi
45 |
46 | hide_output sudo apt -y install libdb5.3 libdb5.3++
47 | echo -e "$GREEN => Complete <=$COL_RESET"
48 |
49 | echo
50 | echo -e "$MAGENTA => Installing additional system files required for daemons <= $COL_RESET"
51 | hide_output sudo apt-get update
52 | apt_install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev libboost-all-dev libminiupnpc-dev \
53 | libqt5gui5 libqt5core5a libqt5webkit5-dev libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler libqrencode-dev libzmq3-dev \
54 | libgmp-dev cmake libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libldns-dev libexpat1-dev libpgm-dev libhidapi-dev \
55 | libusb-1.0-0-dev libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev \
56 | libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz default-libmysqlclient-dev \
57 | libnghttp2-dev librtmp-dev libssh2-1 libssh2-1-dev libldap2-dev libidn11-dev libpsl-dev libnatpmp-dev systemtap-sdt-dev qtwayland5
58 |
59 | if [[ ("${DISTRO}" == "18") ]]; then
60 | hide_output sudo apt -y install ibsqlite3-dev
61 | else
62 | hide_output sudo apt -y install libdb-dev
63 | hide_output sudo apt -y install libdb5.3++ libdb5.3++-dev
64 | fi
65 |
66 | echo -e "$GREEN Additional System Files Completed...$COL_RESET"
67 | echo
68 |
69 | # Updating gcc & g++ to version 8
70 | echo
71 | echo -e "$CYAN => Updating gcc & g++ to version 8 $COL_RESET"
72 | hide_output sudo apt-get update
73 | hide_output sudo apt-get -y upgrade
74 | apt_dist_upgrade
75 |
76 | apt_install software-properties-common
77 |
78 | if [[ ("${DISTRO}" == "18") ]]; then
79 | hide_output sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
80 | fi
81 | hide_output sudo apt-get update
82 |
83 | apt_install gcc-8 g++-8
84 |
85 | hide_output sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-8
86 | hide_output sudo update-alternatives --config gcc
87 |
88 | echo -e "$GREEN gcc & g++ Updated...$COL_RESET"
89 |
90 | set +eu +o pipefail
91 | cd $HOME/yiimp_install_script/daemon_builder
92 | source $HOME/yiimp_install_script/daemon_builder/berkeley.sh
--------------------------------------------------------------------------------
/daemon_builder/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | ##################################################################################
4 | # This is the entry point for configuring the system. #
5 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox #
6 | # Updated by Afiniel for yiimpool use... #
7 | ##################################################################################
8 |
9 | source /etc/functions.sh
10 | source /etc/yiimpool.conf
11 |
12 | # Ensure Python reads/writes files in UTF-8. If the machine
13 | # triggers some other locale in Python, like ASCII encoding,
14 | # Python may not be able to read/write files. This is also
15 | # in the management daemon startup script and the cron script.
16 |
17 | if ! locale -a | grep en_US.utf8 > /dev/null; then
18 | # Generate locale if not exists
19 | hide_output locale-gen en_US.UTF-8
20 | fi
21 |
22 | export LANGUAGE=en_US.UTF-8
23 | export LC_ALL=en_US.UTF-8
24 | export LANG=en_US.UTF-8
25 | export LC_TYPE=en_US.UTF-8
26 |
27 | # Fix so line drawing characters are shown correctly in Putty on Windows.
28 | export NCURSES_NO_UTF8_ACS=1
29 |
30 | # Create DaemonBuilder directory
31 | if [ ! -d $STORAGE_ROOT/daemon_builder ]; then
32 | sudo mkdir -p $STORAGE_ROOT/daemon_builder
33 | fi
34 |
35 | cd $HOME/yiimp_install_script/daemon_builder
36 | source requirements.sh
37 |
38 | cd $HOME/yiimp_install_script/yiimp_single
--------------------------------------------------------------------------------
/daemon_builder/utils/create_user.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | ##################################################################################
4 | # This is the entry point for configuring the system. #
5 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox #
6 | # Updated by Afiniel for yiimpool use... #
7 | ##################################################################################
8 |
9 | source /etc/yiimpoolversion.conf
10 | source /etc/functions.sh
11 | cd ~/yiimp_install_script/install
12 | clear
13 |
14 | # Welcome
15 | message_box "Yiimpool Installer $VERSION" \
16 | "Hello and thanks for using the Yiimpool Yiimp Installer!
17 | \n\nInstallation for the most part is fully automated. In most cases any user responses that are needed are asked prior to the installation.
18 | \n\nNOTE: You should only install this on a brand new Ubuntu 20.04 , Ubuntu 18.04 or Ubuntu 16.04 installation."
19 |
20 | # Root warning message box
21 | message_box "Yiimpool Installer $VERSION" \
22 | "WARNING: You are about to run this script as root!
23 | \n\n The program will create a new user account with sudo privileges.
24 | \n\nThe next step, you will be asked to create a new user account, you can name it whatever you want."
25 |
26 | # Ask if SSH key or password user
27 | dialog --title "Create New User With SSH Key" \
28 | --yesno "Do you want to create new user with SSH key login?
29 | Selecting no will create user with password login only." 7 60
30 | response=$?
31 | case $response in
32 | 0) UsingSSH=yes ;;
33 | 1) UsingSSH=no ;;
34 | 255) echo "[ESC] key pressed." ;;
35 | esac
36 |
37 | # If Using SSH Key Login
38 | if [[ ("$UsingSSH" == "yes") ]]; then
39 | clear
40 | if [ -z "${yiimpadmin:-}" ]; then
41 | DEFAULT_yiimpadmin=yiimpadmin
42 | input_box "New username" \
43 | "Please enter your new username.
44 | \n\nUser Name:" \
45 | ${DEFAULT_yiimpadmin} \
46 | yiimpadmin
47 |
48 | if [ -z "${yiimpadmin}" ]; then
49 | # user hit ESC/cancel
50 | exit
51 | fi
52 | fi
53 |
54 | if [ -z "${ssh_key:-}" ]; then
55 | DEFAULT_ssh_key=PublicKey
56 | input_box "Please open PuTTY Key Generator on your local machine and generate a new public key." \
57 | "To paste your Public key use ctrl shift right click.
58 | \n\nPublic Key:" \
59 | ${DEFAULT_ssh_key} \
60 | ssh_key
61 |
62 | if [ -z "${ssh_key}" ]; then
63 | # user hit ESC/cancel
64 | exit
65 | fi
66 | fi
67 |
68 | # create random user password
69 | RootPassword=$(openssl rand -base64 8 | tr -d "=+/")
70 | clear
71 |
72 | # Add user
73 | echo -e "$YELLOW => Adding new user and setting SSH key... <= $COL_RESET"
74 | sudo adduser ${yiimpadmin} --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
75 | echo -e "${RootPassword}\n${RootPassword}" | passwd ${yiimpadmin}
76 | sudo usermod -aG sudo ${yiimpadmin}
77 |
78 | # Create SSH Key structure
79 | mkdir -p /home/${yiimpadmin}/.ssh
80 | touch /home/${yiimpadmin}/.ssh/authorized_keys
81 | chown -R ${yiimpadmin}:${yiimpadmin} /home/${yiimpadmin}/.ssh
82 | chmod 700 /home/${yiimpadmin}/.ssh
83 | chmod 644 /home/${yiimpadmin}/.ssh/authorized_keys
84 | authkeys=/home/${yiimpadmin}/.ssh/authorized_keys
85 | echo "$ssh_key" >"$authkeys"
86 |
87 | # enabling yiimpool command
88 | echo '# yiimp
89 | # It needs passwordless sudo functionality.
90 | '""''"${yiimpadmin}"''""' ALL=(ALL) NOPASSWD:ALL
91 | ' | sudo -E tee /etc/sudoers.d/${yiimpadmin} >/dev/null 2>&1
92 |
93 | echo '
94 | cd ~/yiimp_install_script/install
95 | bash start.sh
96 | ' | sudo -E tee /usr/bin/yiimpool >/dev/null 2>&1
97 | sudo chmod +x /usr/bin/yiimpool
98 |
99 | # Check required files and set global variables
100 | cd $HOME/yiimp_install_script/install
101 | source pre_setup.sh
102 |
103 | # Create the STORAGE_USER and STORAGE_ROOT directory if they don't already exist.
104 | if ! id -u $STORAGE_USER >/dev/null 2>&1; then
105 | sudo useradd -m $STORAGE_USER
106 | fi
107 | if [ ! -d $STORAGE_ROOT ]; then
108 | sudo mkdir -p $STORAGE_ROOT
109 | fi
110 |
111 | # Save the global options in /etc/yiimpool.conf so that standalone
112 | # tools know where to look for data.
113 | echo 'STORAGE_USER='"${STORAGE_USER}"'
114 | STORAGE_ROOT='"${STORAGE_ROOT}"'
115 | PUBLIC_IP='"${PUBLIC_IP}"'
116 | PUBLIC_IPV6='"${PUBLIC_IPV6}"'
117 | DISTRO='"${DISTRO}"'
118 | VERSION='"$VERSION"'
119 | PRIVATE_IP='"${PRIVATE_IP}"'' | sudo -E tee /etc/yiimpool.conf >/dev/null 2>&1
120 |
121 | # Set Donor Addresses
122 | echo 'BTCDON="BTC: bc1q3k7ag4tf45x60swzuk3djvkelw3xdfkgpjxjm0"
123 | LTCDON="ltc1qqw7cv4snx9ctmpcf25x26lphqluly4w6m073qw"
124 | ETHDON="0x50C7d0BF9714dBEcDc1aa6Ab0E72af8e6Ce3b0aB"
125 | BCHDON="qzz0aff2k0xnwyzg7k9fcxlndtaj4wa65uxteqe84m"
126 | DOGEDON="D7bjqNwyevTYK9JDZbJPQJXbd1b7PosPDT"' | sudo -E tee /etc/yiimpooldonate.conf >/dev/null 2>&1
127 |
128 | sudo cp -r ~/yiimp_install_script /home/${yiimpadmin}/
129 | cd ~
130 | sudo setfacl -m u:${yiimpadmin}:rwx /home/${yiimpadmin}/yiimp_install_script
131 | sudo rm -r $HOME/yiimpool
132 | clear
133 | echo -e "$YELLOW New User:$MAGENTA ${yiimpadmin} $GREEN created!$YELLOW Make sure you save your$RED private key!$COL_RESET"
134 | echo
135 | echo -e "$RED Please reboot system and log in as $GREEN ${yiimpadmin} $RED and type$GREEN yiimpool$RED to$GREEN continue$YELLOW setup...$COL_RESET"
136 | exit 0
137 | fi
138 |
139 | # New User Password Login Creation
140 | if [ -z "${yiimpadmin:-}" ]; then
141 | DEFAULT_yiimpadmin=yiimpadmin
142 | input_box "Creaete new username" \
143 | "Please enter your new username.
144 | \n\nUser Name:" \
145 | ${DEFAULT_yiimpadmin} \
146 | yiimpadmin
147 |
148 | if [ -z "${yiimpadmin}" ]; then
149 | # user hit ESC/cancel
150 | exit
151 | fi
152 | fi
153 |
154 | if [ -z "${RootPassword:-}" ]; then
155 | DEFAULT_RootPassword=$(openssl rand -base64 8 | tr -d "=+/")
156 | input_box "User Password" \
157 | "Enter your new user password or use this randomly system generated one.
158 | \n\nUnfortunatley dialog doesnt let you copy. So you have to write it down.
159 | \n\nUser password:" \
160 | ${DEFAULT_RootPassword} \
161 | RootPassword
162 |
163 | if [ -z "${RootPassword}" ]; then
164 | # user hit ESC/cancel
165 | exit
166 | fi
167 | fi
168 |
169 | clear
170 |
171 | dialog --title "Verify Your input" \
172 | --yesno "Please verify your answers before you continue:
173 | New User Name : ${yiimpadmin}
174 | New User Pass : ${RootPassword}" 8 60
175 |
176 | # Get exit status
177 | # 0 means user hit [yes] button.
178 | # 1 means user hit [no] button.
179 | # 255 means user hit [Esc] key.
180 | response=$?
181 | case $response in
182 |
183 | 0)
184 | clear
185 | echo -e "$YELLOW => Adding new user and password... <= $COL_RESET"
186 |
187 | sudo adduser ${yiimpadmin} --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
188 | echo -e ""${RootPassword}"\n"${RootPassword}"" | passwd ${yiimpadmin}
189 | sudo usermod -aG sudo ${yiimpadmin}
190 |
191 | # enabling yiimpool command
192 | echo '# yiimp
193 | # It needs passwordless sudo functionality.
194 | '""''"${yiimpadmin}"''""' ALL=(ALL) NOPASSWD:ALL
195 | ' | sudo -E tee /etc/sudoers.d/${yiimpadmin} >/dev/null 2>&1
196 |
197 | echo '
198 | cd ~/yiimp_install_script/install
199 | bash start.sh
200 | ' | sudo -E tee /usr/bin/yiimpool >/dev/null 2>&1
201 | sudo chmod +x /usr/bin/yiimpool
202 |
203 | # Check required files and set global variables
204 | cd $HOME/yiimp_install_script/install
205 | source pre_setup.sh
206 |
207 | # Create the STORAGE_USER and STORAGE_ROOT directory if they don't already exist.
208 | if ! id -u $STORAGE_USER >/dev/null 2>&1; then
209 | sudo useradd -m $STORAGE_USER
210 | fi
211 | if [ ! -d $STORAGE_ROOT ]; then
212 | sudo mkdir -p $STORAGE_ROOT
213 | fi
214 |
215 | # Save the global options in /etc/yiimpool.conf so that standalone
216 | # tools know where to look for data.
217 | echo 'STORAGE_USER='"${STORAGE_USER}"'
218 | STORAGE_ROOT='"${STORAGE_ROOT}"'
219 | PUBLIC_IP='"${PUBLIC_IP}"'
220 | PUBLIC_IPV6='"${PUBLIC_IPV6}"'
221 | DISTRO='"${DISTRO}"'
222 | VERSION='"$VERSION"'
223 | PRIVATE_IP='"${PRIVATE_IP}"'' | sudo -E tee /etc/yiimpool.conf >/dev/null 2>&1
224 |
225 | # Set Donor Addresses
226 | echo 'BTCDON="bc1q3k7ag4tf45x60swzuk3djvkelw3xdfkgpjxjm0"
227 | LTCDON="ltc1qqw7cv4snx9ctmpcf25x26lphqluly4w6m073qw"
228 | ETHDON="0x50C7d0BF9714dBEcDc1aa6Ab0E72af8e6Ce3b0aB"
229 | BCHDON="qzz0aff2k0xnwyzg7k9fcxlndtaj4wa65uxteqe84m"
230 | DOGEDON="D7bjqNwyevTYK9JDZbJPQJXbd1b7PosPDT"' | sudo -E tee /etc/yiimpooldonate.conf >/dev/null 2>&1
231 |
232 | sudo cp -r ~/yiimp_install_script /home/${yiimpadmin}/
233 | cd ~
234 | sudo setfacl -m u:${yiimpadmin}:rwx /home/${yiimpadmin}/yiimp_install_script
235 | sudo rm -r $HOME/yiimp_install_script
236 | clear
237 | echo -e "$YELLOW New User:$MAGENTA ${yiimpadmin} $GREEN created$RED $COL_RESET"
238 | echo
239 | echo -e "$YELLOW Please$RED reboot$YELLOW system and log in as the new user:$MAGENTA ${yiimpadmin} $YELLOW and type$GREEN yiimpool$YELLOW to$GREEN continue$YELLOW setup.$COL_RESET"
240 | exit 0
241 | ;;
242 |
243 | 1)
244 |
245 | clear
246 | bash $(basename $0) && exit
247 | ;;
248 |
249 | 255) ;;
250 |
251 | esac
252 |
--------------------------------------------------------------------------------
/daemon_builder/utils/menu.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | #
4 | # This is the main menu For Daemon Builder
5 | #
6 | # Author: Afiniel
7 | #
8 | # Updated: 2023-03-20
9 | #
10 |
11 | source /etc/yiimpoolversion.conf
12 | source /etc/daemonbuilder.sh
13 | source $STORAGE_ROOT/daemon_builder/conf/info.sh
14 |
15 | cd $STORAGE_ROOT/daemon_builder
16 |
17 | LATESTVER=$(curl -sL 'https://api.github.com/repos/Afiniel/yiimp_install_script/releases/latest' | jq -r '.tag_name')
18 |
19 |
20 | if [[ ("{$LATESTVER}" > "{$VERSION}" && "${LATESTVER}" != "null") ]]; then
21 | echo "New version available: ${LATESTVER}"
22 | echo "Your version: ${VERSION}"
23 | echo "Do you want to update? (y/n)"
24 | read -r UPDATE
25 | if [[ ("${UPDATE}" == "y" || "${UPDATE}" == "Y") ]]; then
26 | echo "Updating..."
27 | cd $HOME/yiimp_install_script
28 | git pull
29 | echo "Update complete!"
30 | exit 0
31 | fi
32 | else
33 | RESULT=$(dialog --stdout --title "DaemonBuilder $VERSION" --menu "Choose an option" 13 60 8 \
34 | 1 "Build Coin Daemon From Source Code" \
35 | 2 exit)
36 |
37 | if [ "$RESULT" = "1" ]; then
38 | clear;
39 | cd $STORAGE_ROOT/daemon_builder
40 | source menu1.sh
41 | fi
42 |
43 | if [ "$RESULT" = "2" ]; then
44 | clear;
45 | echo "You have chosen to exit the Daemon Builder. Type: daemonbuilder anytime to start the menu again.";
46 | exit;
47 | fi
48 | fi
--------------------------------------------------------------------------------
/daemon_builder/utils/menu1.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | #
4 | # This is the main menu For Daemon Builder
5 | #
6 | # Author: Afiniel
7 | #
8 | # Updated: 2024-01-03
9 | #
10 |
11 | source /etc/daemonbuilder.sh
12 |
13 | source $STORAGE_ROOT/daemon_builder
14 |
15 | RESULT=$(dialog --stdout --title "DaemonBuilder $VERSION" --menu "Choose an option" 16 60 9 \
16 | ' ' "- Install coin with Berkeley autogen file -" \
17 | 1 "Berkeley 4.8" \
18 | 2 "Berkeley 5.1" \
19 | 3 "Berkeley 5.3" \
20 | 4 "Berkeley 6.2" \
21 | ' ' "- Other choices -" \
22 | 5 "Install coin with makefile.unix file" \
23 | 6 "Install coin with CMake file & DEPENDS folder" \
24 | 7 "Install coin with UTIL folder contains BULD.sh" \
25 | 8 "Install precompiled coin. NEED TO BE LINUX Version!" \
26 | 9 exit)
27 |
28 | if [ "$RESULT" = "1" ]; then
29 | clear;
30 | echo '
31 | autogen=true
32 | berkeley="4.8"
33 | ' | sudo -E tee $STORAGE_ROOT/daemon_builder/.daemon_builder.my.cnf >/dev/null 2>&1;
34 | source source.sh;
35 |
36 | elif [ "$RESULT" = "2" ]; then
37 | clear;
38 | echo '
39 | autogen=true
40 | berkeley="5.1"
41 | ' | sudo -E tee $STORAGE_ROOT/daemon_builder/.daemon_builder.my.cnf >/dev/null 2>&1;
42 | source source.sh;
43 |
44 | elif [ "$RESULT" = "3" ]; then
45 | clear;
46 | echo '
47 | autogen=true
48 | berkeley="5.3"
49 | ' | sudo -E tee $STORAGE_ROOT/daemon_builder/.daemon_builder.my.cnf >/dev/null 2>&1;
50 | source source.sh;
51 |
52 | elif [ "$RESULT" = "4" ]; then
53 | clear;
54 | echo '
55 | autogen=true
56 | berkeley="6.2"
57 | ' | sudo -E tee $STORAGE_ROOT/daemon_builder/.daemon_builder.my.cnf >/dev/null 2>&1;
58 | source source.sh;
59 |
60 | elif [ "$RESULT" = "5" ]; then
61 | clear;
62 | echo '
63 | autogen=false
64 | unix=true
65 | ' | sudo -E tee $STORAGE_ROOT/daemon_builder/.daemon_builder.my.cnf >/dev/null 2>&1;
66 | source source.sh;
67 |
68 | elif [ "$RESULT" = "6" ]; then
69 | clear;
70 | echo '
71 | autogen=false
72 | cmake=true
73 | ' | sudo -E tee $STORAGE_ROOT/daemon_builder/.daemon_builder.my.cnf >/dev/null 2>&1;
74 | source source.sh;
75 |
76 | elif [ "$RESULT" = "7" ]; then
77 | clear;
78 | echo '
79 | buildutil=true
80 | autogen=true
81 | ' | sudo -E tee $STORAGE_ROOT/daemon_builder/.daemon_builder.my.cnf >/dev/null 2>&1;
82 | source source.sh;
83 |
84 | elif [ "$RESULT" = "8" ]; then
85 | clear;
86 | echo '
87 | precompiled=true
88 | ' | sudo -E tee $STORAGE_ROOT/daemon_builder/.daemon_builder.my.cnf >/dev/null 2>&1;
89 | source source.sh;
90 |
91 | elif [ "$RESULT" = "9" ]; then
92 | clear;
93 | echo "You have chosen to exit the Daemon Builder. Type: daemonbuilder anytime to start the menu again.";
94 | exit;
95 | fi
--------------------------------------------------------------------------------
/daemon_builder/utils/menu2.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #####################################################
3 | # Updated by Afiniel
4 | # Menu: Add Coin to Dedicated Port and run stratum
5 | #####################################################
6 |
7 | source /etc/daemonbuilder.sh
8 | source $STORAGE_ROOT/daemon_builder/conf/info.sh
9 |
10 | cd ~
11 | clear
12 |
13 | sudo addport
14 |
15 | echo -e "$CYAN --------------------------------------------------------------------------- $COL_RESET"
16 | echo -e "$RED Type ${daemonname} at anytime to Add Port & run Stratum $COL_RESET"
17 | echo -e "$CYAN --------------------------------------------------------------------------- $COL_RESET"
18 | exit
19 |
--------------------------------------------------------------------------------
/daemon_builder/utils/menu3.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #####################################################
3 | # Updated by Afiniel
4 | # Menu: Update new Stratum
5 | #####################################################
6 |
7 | source /etc/daemonbuilder.sh
8 | source $STORAGE_ROOT/daemon_builder/conf/info.sh
9 |
10 | message_box " Stratum compiler " \
11 | "This Scrypt of Stratum run in future builds sorry
12 | \n\nCheck again later in Update this scrypt Menu"
13 |
14 | cd ~
15 | clear
16 |
17 | echo -e "$CYAN --------------------------------------------------------------------------- $COL_RESET"
18 | echo -e "$RED Type ${daemonname} at anytime to run this Scrypt! $COL_RESET"
19 | echo -e "$CYAN --------------------------------------------------------------------------- $COL_RESET"
20 | exit
21 |
--------------------------------------------------------------------------------
/daemon_builder/utils/menu4.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #####################################################
3 | # Updated by Afiniel
4 | # Updrade this scrypt
5 | #####################################################
6 |
7 | source /etc/daemonbuilder.sh
8 | source $STORAGE_ROOT/daemon_builder/conf/info.sh
9 |
10 | if [[ ("${LATESTVER}" > "${VERSION}" && "${LATESTVER}" != "null") ]]; then
11 | message_box " Updating This script to ${LATESTVER}" \
12 | "You are currently using version ${VERSION}
13 | \n\nAre you going to update it to the version ${LATESTVER}"
14 | TAG="${LATESTVER}"
15 |
16 | cd ~
17 | clear
18 |
19 | hide_output sudo git config --global url."https://github.com/".insteadOf git@github.com:
20 | hide_output sudo git config --global url."https://".insteadOf git://
21 | sleep 1
22 |
23 | REPO="Afiniel/yiimp_install_script"
24 |
25 | temp_dir="$(tempfile -d)" && \
26 | git clone -q git@github.com:${REPO%.git} "${temp_dir}" && \
27 | cd "${temp_dir}/" && \
28 | git -c advice.detachedHead=false checkout -q tags/${TAG}
29 | sleep 1
30 | test $? -eq 0 ||
31 | {
32 | echo
33 | echo -e "$RED Error cloning repository. $COL_RESET";
34 | echo
35 | sudo rm -f $temp_dir
36 | exit 1;
37 | }
38 |
39 | FILEINSTALLEXIST="${temp_dir}/install.sh"
40 | if [ -f "$FILEINSTALLEXIST" ]; then
41 | hide_output sudo chown -R $USER ${temp_dir}
42 | sleep 1
43 | cd ${temp_dir}
44 | sudo find . -type f -name "*.sh" -exec chmod -R +x {} \;
45 | sleep 1
46 | ./install.sh "${temp_dir}"
47 | fi
48 |
49 | sudo rm -rf $temp_dir
50 |
51 | echo -e "$CYAN -------------------------------------------------------------------------- $COL_RESET"
52 | echo -e "$GREEN Updating is Finish! $COL_RESET"
53 | echo -e "$CYAN -------------------------------------------------------------------------- $COL_RESET"
54 | echo
55 | cd ~
56 | exit
57 |
58 | else
59 | message_box " Updating This script " \
60 | "Check if this scrypt needs update.
61 | \nyou already have the latest version installed!
62 | \nYour Version is: ${VERSION}"
63 |
64 | cd ~
65 | clear
66 | echo -e "$CYAN -------------------------------------------------------------------------- $COL_RESET"
67 | echo -e "$RED Thank you using this scrpt! $COL_RESET"
68 | echo -e "$CYAN -------------------------------------------------------------------------- $COL_RESET"
69 | echo
70 | echo -e "$CYAN -------------------------------------------------------------------------- $COL_RESET"
71 | echo -e "$GREEN Donations are welcome at wallets below: $COL_RESET"
72 | echo -e "$YELLOW BTC: $COL_RESET $MAGENTA ${BTCDEP} $COL_RESET"
73 | echo -e "$YELLOW LTC: $COL_RESET $MAGENTA ${LTCDEP} $COL_RESET"
74 | echo -e "$YELLOW ETH: $COL_RESET $MAGENTA ${ETHDEP} $COL_RESET"
75 | echo -e "$YELLOW BCH: $COL_RESET $MAGENTA ${DOGEDEP} $COL_RESET"
76 | echo -e "$CYAN -------------------------------------------------------------------------- $COL_RESET"
77 | echo
78 | cd ~
79 | exit
80 |
81 | fi
82 |
83 |
--------------------------------------------------------------------------------
/daemon_builder/utils/screen-scrypt-daemonbuilder.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | source /etc/daemonbuilder.sh
4 | source $STORAGE_ROOT/daemon_builder/conf/info.sh
5 |
6 | LOG_DIR=/var/log/daemon-coin
7 | STRATUM_DIR=${PATH_STRATUM}
8 | USR_BIN=/usr/bin
9 |
--------------------------------------------------------------------------------
/daemon_builder/utils/start.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #####################################################
3 | # This is the entry point for configuring the system.
4 | # Updated by Afiniel
5 | #####################################################
6 |
7 | source /etc/daemonbuilder.sh
8 | source /etc/functions.sh
9 | source $STORAGE_ROOT/yiimp/.yiimp.conf
10 |
11 | source /etc/yiimpool.conf
12 | source $STORAGE_ROOT/daemon_builder/conf/info.sh
13 |
14 | cd $STORAGE_ROOT/daemon_builder
15 | # Ensure Python reads/writes files in UTF-8. If the machine
16 | # triggers some other locale in Python, like ASCII encoding,
17 | # Python may not be able to read/write files. This is also
18 | # in the management daemon startup script and the cron script.
19 |
20 | if ! locale -a | grep en_US.utf8 > /dev/null; then
21 | # Generate locale if not exists
22 | sudo locale-gen en_US.UTF-8
23 | fi
24 |
25 | export LANGUAGE=en_US.UTF-8
26 | export LC_ALL=en_US.UTF-8
27 | export LANG=en_US.UTF-8
28 | export LC_TYPE=en_US.UTF-8
29 |
30 | # Fix so line drawing characters are shown correctly in Putty on Windows. See #744.
31 | export NCURSES_NO_UTF8_ACS=1
32 |
33 | if (( $EUID == 0 )); then
34 | # Welcome
35 | message_box "daemonbuilder" \
36 | "Hello and thanks for using the daemonbuilder
37 | \nYou are logged in to ROOT
38 | \n\nIMPORTANT: Please run this scrypt logged in USER Thanks you."
39 | cd ..
40 | cd ~
41 | clear
42 | exit;
43 | else
44 | message_box " Daemon Installer " \
45 | "Warning! This Scrypt only works with servers setup with the Yiimpool installer!
46 | \n\nSetup for the most part is fully automated. Very little user input is required."
47 |
48 | # Start the installation.
49 | source menu.sh
50 | fi
51 |
--------------------------------------------------------------------------------
/daemon_builder/utils/stratum.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ################################################################################
3 | #
4 | # Install Stratum OR Update on Ubuntu 18.04/20.04
5 | # v0.1 (update December, 2022)
6 | #
7 | ################################################################################
8 |
9 | clear
10 |
11 | output() {
12 | printf "\E[0;33;40m"
13 | echo $1
14 | printf "\E[0m"
15 | }
16 |
17 | displayErr() {
18 | echo
19 | echo $1;
20 | echo
21 | exit 1;
22 | }
23 |
24 | whoami=`whoami`
25 |
26 | source /etc/daemonbuilder.sh
27 |
28 | source $HOME/${installtoserver}/conf/coin.sh
29 | term_art
30 |
31 | echo
32 | echo
33 | echo -e "$RED Install Straum OR update!! $COL_RESET"
34 | echo
35 |
36 | # Installing Stratum
37 | echo
38 | echo
39 | echo -e "$MAGENTA => Installing Stratum $COL_RESET"
40 | echo
41 | echo -e "Grabbing Stratum fron Github, building files and setting file structure."
42 | echo
43 | sleep 3
44 |
45 | # Compil Blocknotify
46 | cd ~
47 | hide_output git clone https://github.com/Afiniel/stratum
48 | sudo chmod -R 777 $HOME/stratum/
49 | cd $HOME/stratum/blocknotify
50 | sudo sed -i 's/tu8tu5/'$PASSWORD_STRATUM'/' blocknotify.cpp
51 | hide_output sudo make -j$(nproc)
52 | sleep 3
53 |
54 | # Compil iniparser
55 | cd $HOME/stratum
56 | hide_output sudo make -C iniparser/ -j$(nproc)
57 | sleep 3
58 |
59 | # Compil algos
60 | hide_output sudo make -C algos/ -j$(nproc)
61 | sleep 3
62 |
63 | # Compil sha3
64 | hide_output sudo make -C sha3 -j$(nproc)
65 | sleep 3
66 |
67 | whoami=`whoami`
68 | echo
69 | echo -e "$RED Enter password for ROOT server : $COL_RESET"
70 | echo
71 | su root
72 | cd $HOME/$whoami/${installtoserver}/stratum
73 |
74 | # Compil stratum
75 | hide_output sudo make -f Makefile -j$(nproc)
76 | sleep 3
77 |
78 | su $whoami
79 | cd $HOME/stratum
80 |
81 | # Copy Files (Blocknotify,iniparser,Stratum)
82 | sudo mkdir -p /home/crypto-data/yiimp/site/stratum
83 | sudo cp -a config.sample/. /home/crypto-data/yiimp/site/stratum/config
84 | sudo cp -r stratum /home/crypto-data/yiimp/site/stratum
85 | sudo cp -r run.sh /home/crypto-data/yiimp/site/stratum
86 | sudo cp -r $HOME/stratum/bin/. /bin/
87 | sudo cp -r $HOME/stratum/blocknotify/blocknotify /usr/bin/
88 | sudo cp -r $HOME/stratum/blocknotify/blocknotify /home/crypto-data/yiimp/site/stratum/
89 | sleep 3
90 |
91 | #fixing run.sh
92 | sudo rm -r /home/crypto-data/yiimp/site/stratum/config/run.sh
93 | echo '
94 | #!/bin/bash
95 | ulimit -n 10240
96 | ulimit -u 10240
97 | cd /home/crypto-data/yiimp/site/stratum
98 | while true; do
99 | ./stratum /home/crypto-data/yiimp/site/stratum/config/$1
100 | sleep 2
101 | done
102 | exec bash
103 | ' | sudo -E tee /home/crypto-data/yiimp/site/stratum/config/run.sh >/dev/null 2>&1
104 | sudo chmod +x /home/crypto-data/yiimp/site/stratum/config/run.sh
105 |
106 | echo -e "$GREEN Done...$COL_RESET"
107 | sleep 3
108 |
109 | # Update Timezone
110 | echo
111 | echo
112 | echo -e "$CYAN => Update default timezone. $COL_RESET"
113 | echo
114 |
115 | echo -e " Setting TimeZone to UTC...$COL_RESET"
116 | if [ ! -f /etc/timezone ]; then
117 | echo "Setting timezone to UTC."
118 | echo "Etc/UTC" > sudo /etc/timezone
119 | sudo systemctl restart rsyslog
120 | fi
121 | sudo systemctl status rsyslog | sed -n "1,3p"
122 | echo
123 | echo -e "$GREEN Done...$COL_RESET"
124 | sleep 3
125 |
126 | # Updating stratum config files with database connection info
127 | echo
128 | echo
129 | echo -e "$CYAN => Updating stratum config files with database connection info. $COL_RESET"
130 | echo
131 | sleep 3
132 |
133 | cd /home/crypto-data/yiimp/site/stratum/config
134 | sudo sed -i 's/password = tu8tu5/password = '$PASSWORD_STRATUM'/g' *.conf
135 | sudo sed -i 's/server = yaamp.com/server = '$SERVER_STRATUM'/g' *.conf
136 | sudo sed -i 's/host = yaampdb/host = '$SERVER_STRATUM'/g' *.conf
137 | sudo sed -i 's/database = yaamp/database = '$MYSQL_DATABASE'/g' *.conf
138 | sudo sed -i 's/username = root/username = '$MYSQL_USER'/g' *.conf
139 | sudo sed -i 's/password = patofpaq/password = '$MYSQL_PASSWORD'/g' *.conf
140 | cd ~
141 | echo -e "$GREEN Done...$COL_RESET"
142 |
143 | # Final Directory permissions
144 | echo
145 | echo
146 | echo -e "$CYAN => Final Directory permissions $COL_RESET"
147 | echo
148 | sleep 3
149 |
150 | sudo chgrp www-data /home/crypto-data/yiimp/site/stratum -R
151 | sudo chmod 775 /home/crypto-data/yiimp/site/stratum
152 |
153 | #Misc
154 | sudo rm -rf $HOME/stratum-install-finish
155 | sudo mv $HOME/stratum/ $HOME/stratum-install-finish
156 |
157 | echo
158 | echo -e "$GREEN Done...$COL_RESET"
159 | sleep 3
160 |
161 | echo
162 | install_end_message
163 | echo
164 | echo
165 | cd ~
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #########################################################
3 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox
4 | # Updated by Afiniel for Yiimpool use...
5 | # This script is intended to be run like this:
6 | #
7 | # curl https://raw.githubusercontent.com/afiniel/yiimp_install_script/master/install.sh | bash
8 | #
9 | #########################################################
10 |
11 | if [ -z "${TAG}" ]; then
12 | TAG=v0.9.3
13 | fi
14 |
15 | echo 'VERSION='"${TAG}"'' | sudo -E tee /etc/yiimpoolversion.conf >/dev/null 2>&1
16 |
17 | # Clone the Yiimp Install Script repository if it doesn't exist.
18 | if [ ! -d $HOME/yiimp_install_script ]; then
19 | if [ ! -f /usr/bin/git ]; then
20 | echo Installing git . . .
21 | apt-get -q -q update
22 | DEBIAN_FRONTEND=noninteractive apt-get -q -q install -y git < /dev/null
23 | clear
24 | echo
25 |
26 | fi
27 |
28 | echo Downloading Yiimpool Installer ${TAG}. . .
29 | git clone \
30 | -b ${TAG} --depth 1 \
31 | https://github.com/afiniel/yiimp_install_script \
32 | "$HOME"/yiimp_install_script \
33 | < /dev/null 2> /dev/null
34 |
35 | echo
36 | fi
37 |
38 |
39 | cd $HOME/yiimp_install_script/
40 |
41 | # Update it.
42 | sudo chown -R $USER $HOME/yiimp_install_script/.git/
43 | if [ "${TAG}" != `git describe --tags` ]; then
44 | echo Updating Yiimpool Installer to ${TAG} . . .
45 | git fetch --depth 1 --force --prune origin tag ${TAG}
46 | if ! git checkout -q ${TAG}; then
47 | echo "Update failed. Did you modify something in `pwd`?"
48 | exit
49 | fi
50 | echo
51 | fi
52 |
53 | # Start setup script.
54 | bash $HOME/yiimp_install_script/install/start.sh
55 |
--------------------------------------------------------------------------------
/install/bootstrap_coin.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | ##################################################################################
4 | # This is the entry point for configuring the system. #
5 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox #
6 | # Updated by Afiniel for yiimpool use... #
7 | ##################################################################################
--------------------------------------------------------------------------------
/install/bootstrap_upgrade.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | ##################################################################################
4 | # This is the entry point for configuring the system. #
5 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox #
6 | # Updated by Afiniel for yiimpool use... #
7 | ##################################################################################
--------------------------------------------------------------------------------
/install/create_user.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | ##################################################################################
4 | # This is the entry point for configuring the system. #
5 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox #
6 | # Updated by Afiniel for yiimpool use... #
7 | ##################################################################################
8 |
9 | source /etc/yiimpoolversion.conf
10 | source /etc/functions.sh
11 | cd ~/yiimp_install_script/install
12 | clear
13 |
14 | # Welcome
15 | message_box "Yiimpool Installer $VERSION" \
16 | "Hello and thanks for using the Yiimpool Yiimp Installer!
17 | \n\nInstallation for the most part is fully automated. In most cases any user responses that are needed are asked prior to the installation.
18 | \n\nNOTE: You should only install this on a brand new Ubuntu 20.04 , Ubuntu 18.04 or Ubuntu 16.04 installation."
19 |
20 | # Root warning message box
21 | message_box "Yiimpool Installer $VERSION" \
22 | "WARNING: You are about to run this script as root!
23 | \n\n The program will create a new user account with sudo privileges.
24 | \n\nThe next step, you will be asked to create a new user account, you can name it whatever you want."
25 |
26 | # Ask if SSH key or password user
27 | dialog --title "Create New User With SSH Key" \
28 | --yesno "Do you want to create new user with SSH key login?
29 | Selecting no will create user with password login only." 7 60
30 | response=$?
31 | case $response in
32 | 0) UsingSSH=yes ;;
33 | 1) UsingSSH=no ;;
34 | 255) echo "[ESC] key pressed." ;;
35 | esac
36 |
37 | # If Using SSH Key Login
38 | if [[ ("$UsingSSH" == "yes") ]]; then
39 | clear
40 | if [ -z "${yiimpadmin:-}" ]; then
41 | DEFAULT_yiimpadmin=yiimpadmin
42 | input_box "New username" \
43 | "Please enter your new username.
44 | \n\nUser Name:" \
45 | ${DEFAULT_yiimpadmin} \
46 | yiimpadmin
47 |
48 | if [ -z "${yiimpadmin}" ]; then
49 | # user hit ESC/cancel
50 | exit
51 | fi
52 | fi
53 |
54 | if [ -z "${ssh_key:-}" ]; then
55 | DEFAULT_ssh_key=PublicKey
56 | input_box "Please open PuTTY Key Generator on your local machine and generate a new public key." \
57 | "To paste your Public key use ctrl shift right click.
58 | \n\nPublic Key:" \
59 | ${DEFAULT_ssh_key} \
60 | ssh_key
61 |
62 | if [ -z "${ssh_key}" ]; then
63 | # user hit ESC/cancel
64 | exit
65 | fi
66 | fi
67 |
68 | # create random user password
69 | RootPassword=$(openssl rand -base64 8 | tr -d "=+/")
70 | clear
71 |
72 | # Add user
73 | echo -e "$YELLOW => Adding new user and setting SSH key... <= $COL_RESET"
74 | sudo adduser ${yiimpadmin} --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
75 | echo -e "${RootPassword}\n${RootPassword}" | passwd ${yiimpadmin}
76 | sudo usermod -aG sudo ${yiimpadmin}
77 |
78 | # Create SSH Key structure
79 | mkdir -p /home/${yiimpadmin}/.ssh
80 | touch /home/${yiimpadmin}/.ssh/authorized_keys
81 | chown -R ${yiimpadmin}:${yiimpadmin} /home/${yiimpadmin}/.ssh
82 | chmod 700 /home/${yiimpadmin}/.ssh
83 | chmod 644 /home/${yiimpadmin}/.ssh/authorized_keys
84 | authkeys=/home/${yiimpadmin}/.ssh/authorized_keys
85 | echo "$ssh_key" >"$authkeys"
86 |
87 | # enabling yiimpool command
88 | echo '# yiimp
89 | # It needs passwordless sudo functionality.
90 | '""''"${yiimpadmin}"''""' ALL=(ALL) NOPASSWD:ALL
91 | ' | sudo -E tee /etc/sudoers.d/${yiimpadmin} >/dev/null 2>&1
92 |
93 | echo '
94 | cd ~/yiimp_install_script/install
95 | bash start.sh
96 | ' | sudo -E tee /usr/bin/yiimpool >/dev/null 2>&1
97 | sudo chmod +x /usr/bin/yiimpool
98 |
99 | # Check required files and set global variables
100 | cd $HOME/yiimp_install_script/install
101 | source pre_setup.sh
102 |
103 | # Create the STORAGE_USER and STORAGE_ROOT directory if they don't already exist.
104 | if ! id -u $STORAGE_USER >/dev/null 2>&1; then
105 | sudo useradd -m $STORAGE_USER
106 | fi
107 | if [ ! -d $STORAGE_ROOT ]; then
108 | sudo mkdir -p $STORAGE_ROOT
109 | fi
110 |
111 | # Save the global options in /etc/yiimpool.conf so that standalone
112 | # tools know where to look for data.
113 | echo 'STORAGE_USER='"${STORAGE_USER}"'
114 | STORAGE_ROOT='"${STORAGE_ROOT}"'
115 | PUBLIC_IP='"${PUBLIC_IP}"'
116 | PUBLIC_IPV6='"${PUBLIC_IPV6}"'
117 | DISTRO='"${DISTRO}"'
118 | PRIVATE_IP='"${PRIVATE_IP}"'' | sudo -E tee /etc/yiimpool.conf >/dev/null 2>&1
119 |
120 | # Set Donor Addresses
121 | echo 'BTCDON="bc1q582gdvyp09038hp9n5sfdtp0plkx5x3yrhq05y"
122 | LTCDON="ltc1qqw7cv4snx9ctmpcf25x26lphqluly4w6m073qw"
123 | ETHDON="0x50C7d0BF9714dBEcDc1aa6Ab0E72af8e6Ce3b0aB"
124 | BCHDON="qzz0aff2k0xnwyzg7k9fcxlndtaj4wa65uxteqe84m"
125 | DOGEDON="DSzcmyCRi7JeN4XUiV2qYhRQAydNv7A1Yb"' | sudo -E tee /etc/yiimpooldonate.conf >/dev/null 2>&1
126 |
127 | sudo cp -r ~/yiimp_install_script /home/${yiimpadmin}/
128 | cd ~
129 | sudo setfacl -m u:${yiimpadmin}:rwx /home/${yiimpadmin}/yiimp_install_script
130 | sudo rm -r $HOME/yiimpool
131 | clear
132 | echo -e "$YELLOW New User:$MAGENTA ${yiimpadmin} $GREEN created!$YELLOW Make sure you save your$RED private key!$COL_RESET"
133 | echo
134 | echo -e "$RED Please reboot system and log in as $GREEN ${yiimpadmin} $RED and type$GREEN yiimpool$RED to$GREEN continue$YELLOW setup...$COL_RESET"
135 | exit 0
136 | fi
137 |
138 | # New User Password Login Creation
139 | if [ -z "${yiimpadmin:-}" ]; then
140 | DEFAULT_yiimpadmin=yiimpadmin
141 | input_box "Creaete new username" \
142 | "Please enter your new username.
143 | \n\nUser Name:" \
144 | ${DEFAULT_yiimpadmin} \
145 | yiimpadmin
146 |
147 | if [ -z "${yiimpadmin}" ]; then
148 | # user hit ESC/cancel
149 | exit
150 | fi
151 | fi
152 |
153 | if [ -z "${RootPassword:-}" ]; then
154 | DEFAULT_RootPassword=$(openssl rand -base64 8 | tr -d "=+/")
155 | input_box "User Password" \
156 | "Enter your new user password or use this randomly system generated one.
157 | \n\nUnfortunatley dialog doesnt let you copy. So you have to write it down.
158 | \n\nUser password:" \
159 | ${DEFAULT_RootPassword} \
160 | RootPassword
161 |
162 | if [ -z "${RootPassword}" ]; then
163 | # user hit ESC/cancel
164 | exit
165 | fi
166 | fi
167 |
168 | clear
169 |
170 | dialog --title "Verify Your input" \
171 | --yesno "Please verify your answers before you continue:
172 | New User Name : ${yiimpadmin}
173 | New User Pass : ${RootPassword}" 8 60
174 |
175 | # Get exit status
176 | # 0 means user hit [yes] button.
177 | # 1 means user hit [no] button.
178 | # 255 means user hit [Esc] key.
179 | response=$?
180 | case $response in
181 |
182 | 0)
183 | clear
184 | echo -e "$YELLOW => Adding new user and password... <= $COL_RESET"
185 |
186 | sudo adduser ${yiimpadmin} --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
187 | echo -e ""${RootPassword}"\n"${RootPassword}"" | passwd ${yiimpadmin}
188 | sudo usermod -aG sudo ${yiimpadmin}
189 |
190 | # enabling yiimpool command
191 | echo '# yiimp
192 | # It needs passwordless sudo functionality.
193 | '""''"${yiimpadmin}"''""' ALL=(ALL) NOPASSWD:ALL
194 | ' | sudo -E tee /etc/sudoers.d/${yiimpadmin} >/dev/null 2>&1
195 |
196 | echo '
197 | cd ~/yiimp_install_script/install
198 | bash start.sh
199 | ' | sudo -E tee /usr/bin/yiimpool >/dev/null 2>&1
200 | sudo chmod +x /usr/bin/yiimpool
201 |
202 | # Check required files and set global variables
203 | cd $HOME/yiimp_install_script/install
204 | source pre_setup.sh
205 |
206 | # Create the STORAGE_USER and STORAGE_ROOT directory if they don't already exist.
207 | if ! id -u $STORAGE_USER >/dev/null 2>&1; then
208 | sudo useradd -m $STORAGE_USER
209 | fi
210 | if [ ! -d $STORAGE_ROOT ]; then
211 | sudo mkdir -p $STORAGE_ROOT
212 | fi
213 |
214 | # Save the global options in /etc/yiimpool.conf so that standalone
215 | # tools know where to look for data.
216 | echo 'STORAGE_USER='"${STORAGE_USER}"'
217 | STORAGE_ROOT='"${STORAGE_ROOT}"'
218 | PUBLIC_IP='"${PUBLIC_IP}"'
219 | PUBLIC_IPV6='"${PUBLIC_IPV6}"'
220 | DISTRO='"${DISTRO}"'
221 |
222 | PRIVATE_IP='"${PRIVATE_IP}"'' | sudo -E tee /etc/yiimpool.conf >/dev/null 2>&1
223 |
224 | # Set Donor Addresses
225 | echo 'BTCDON="bc1q582gdvyp09038hp9n5sfdtp0plkx5x3yrhq05y"
226 | LTCDON="ltc1qqw7cv4snx9ctmpcf25x26lphqluly4w6m073qw"
227 | ETHDON="0x50C7d0BF9714dBEcDc1aa6Ab0E72af8e6Ce3b0aB"
228 | BCHDON="qzz0aff2k0xnwyzg7k9fcxlndtaj4wa65uxteqe84m"
229 | DOGEDON="DSzcmyCRi7JeN4XUiV2qYhRQAydNv7A1Yb"' | sudo -E tee /etc/yiimpooldonate.conf >/dev/null 2>&1
230 |
231 | sudo cp -r ~/yiimp_install_script /home/${yiimpadmin}/
232 | cd ~
233 | sudo setfacl -m u:${yiimpadmin}:rwx /home/${yiimpadmin}/yiimp_install_script
234 | sudo rm -r $HOME/yiimp_install_script
235 | clear
236 | echo -e "$YELLOW New User:$MAGENTA ${yiimpadmin} $GREEN created$RED $COL_RESET"
237 | echo
238 | echo -e "$YELLOW Please$RED reboot$YELLOW system and log in as the new user:$MAGENTA ${yiimpadmin} $YELLOW and type$GREEN yiimpool$YELLOW to$GREEN continue$YELLOW setup.$COL_RESET"
239 | exit 0
240 | ;;
241 |
242 | 1)
243 |
244 | clear
245 | bash $(basename $0) && exit
246 | ;;
247 |
248 | 255) ;;
249 |
250 | esac
251 |
--------------------------------------------------------------------------------
/install/editconf.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | #
3 | # This is a helper tool for editing configuration files during the setup
4 | # process. The tool is given new values for settings as command-line
5 | # arguments. It comments-out existing setting values in the configuration
6 | # file and adds new values either after their former location or at the
7 | # end.
8 | #
9 | # The configuration file has settings that look like:
10 | #
11 | # NAME=VALUE
12 | #
13 | # If the -s option is given, then space becomes the delimiter, i.e.:
14 | #
15 | # NAME VALUE
16 | #
17 | # If the -c option is given, then the supplied character becomes the comment character
18 | #
19 | # If the -w option is given, then setting lines continue onto following
20 | # lines while the lines start with whitespace, e.g.:
21 | #
22 | # NAME VAL
23 | # UE
24 |
25 | import sys, re
26 |
27 | # sanity check
28 | if len(sys.argv) < 3:
29 | print("usage: python3 editconf.py /etc/file.conf [-s] [-w] [-c ] [-t] NAME=VAL [NAME=VAL ...]")
30 | sys.exit(1)
31 |
32 | # parse command line arguments
33 | filename = sys.argv[1]
34 | settings = sys.argv[2:]
35 |
36 | delimiter = "="
37 | delimiter_re = r"\s*=\s*"
38 | comment_char = "#"
39 | folded_lines = False
40 | testing = False
41 | while settings[0][0] == "-" and settings[0] != "--":
42 | opt = settings.pop(0)
43 | if opt == "-s":
44 | # Space is the delimiter
45 | delimiter = " "
46 | delimiter_re = r"\s+"
47 | elif opt == "-w":
48 | # Line folding is possible in this file.
49 | folded_lines = True
50 | elif opt == "-c":
51 | # Specifies a different comment character.
52 | comment_char = settings.pop(0)
53 | elif opt == "-t":
54 | testing = True
55 | else:
56 | print("Invalid option.")
57 | sys.exit(1)
58 |
59 | # sanity check command line
60 | for setting in settings:
61 | try:
62 | name, value = setting.split("=", 1)
63 | except:
64 | import subprocess
65 | print("Invalid command line: ", subprocess.list2cmdline(sys.argv))
66 |
67 | # create the new config file in memory
68 |
69 | found = set()
70 | buf = ""
71 | input_lines = list(open(filename))
72 |
73 | while len(input_lines) > 0:
74 | line = input_lines.pop(0)
75 |
76 | # If this configuration file uses folded lines, append any folded lines
77 | # into our input buffer.
78 | if folded_lines and line[0] not in (comment_char, " ", ""):
79 | while len(input_lines) > 0 and input_lines[0][0] in " \t":
80 | line += input_lines.pop(0)
81 |
82 | # See if this line is for any settings passed on the command line.
83 | for i in range(len(settings)):
84 | # Check that this line contain this setting from the command-line arguments.
85 | name, val = settings[i].split("=", 1)
86 | m = re.match(
87 | "(\s*)"
88 | + "(" + re.escape(comment_char) + "\s*)?"
89 | + re.escape(name) + delimiter_re + "(.*?)\s*$",
90 | line, re.S)
91 | if not m: continue
92 | indent, is_comment, existing_val = m.groups()
93 |
94 | # If this is already the setting, do nothing.
95 | if is_comment is None and existing_val == val:
96 | # It may be that we've already inserted this setting higher
97 | # in the file so check for that first.
98 | if i in found: break
99 | buf += line
100 | found.add(i)
101 | break
102 |
103 | # comment-out the existing line (also comment any folded lines)
104 | if is_comment is None:
105 | buf += comment_char + line.rstrip().replace("\n", "\n" + comment_char) + "\n"
106 | else:
107 | # the line is already commented, pass it through
108 | buf += line
109 |
110 | # if this option oddly appears more than once, don't add the setting again
111 | if i in found:
112 | break
113 |
114 | # add the new setting
115 | buf += indent + name + delimiter + val + "\n"
116 |
117 | # note that we've applied this option
118 | found.add(i)
119 |
120 | break
121 | else:
122 | # If did not match any setting names, pass this line through.
123 | buf += line
124 |
125 | # Put any settings we didn't see at the end of the file.
126 | for i in range(len(settings)):
127 | if i not in found:
128 | name, val = settings[i].split("=", 1)
129 | buf += name + delimiter + val + "\n"
130 |
131 | if not testing:
132 | # Write out the new file.
133 | with open(filename, "w") as f:
134 | f.write(buf)
135 | else:
136 | # Just print the new file to stdout.
137 | print(buf)
--------------------------------------------------------------------------------
/install/existing_user.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | ##################################################################################
4 | # This is the entry point for configuring the system. #
5 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox #
6 | # Updated by Afiniel for yiimpool use... #
7 | ##################################################################################
8 |
9 | source /etc/functions.sh
10 | cd ~/yiimp_install_script/install
11 | clear
12 |
13 | # Get logged in user name
14 | whoami=`whoami`
15 | echo -e " Modifying existing user $whoami for yiimpool support."
16 | sudo usermod -aG sudo ${whoami}
17 |
18 | echo '# yiimp
19 | # It needs passwordless sudo functionality.
20 | '""''"${whoami}"''""' ALL=(ALL) NOPASSWD:ALL
21 | ' | sudo -E tee /etc/sudoers.d/${whoami} >/dev/null 2>&1
22 |
23 | echo '
24 | cd ~/yiimp_install_script/install
25 | bash start.sh
26 | ' | sudo -E tee /usr/bin/yiimpool >/dev/null 2>&1
27 | sudo chmod +x /usr/bin/yiimpool
28 |
29 | # Check required files and set global variables
30 | cd $HOME/yiimp_install_script/install
31 | source pre_setup.sh
32 |
33 | # Create the STORAGE_USER and STORAGE_ROOT directory if they don't already exist.
34 | if ! id -u $STORAGE_USER >/dev/null 2>&1; then
35 | sudo useradd -m $STORAGE_USER
36 | fi
37 | if [ ! -d $STORAGE_ROOT ]; then
38 | sudo mkdir -p $STORAGE_ROOT
39 | fi
40 |
41 | # Save the global options in /etc/yiimpool.conf so that standalone
42 | # tools know where to look for data.
43 | echo 'STORAGE_USER='"${STORAGE_USER}"'
44 | STORAGE_ROOT='"${STORAGE_ROOT}"'
45 | PUBLIC_IP='"${PUBLIC_IP}"'
46 | PUBLIC_IPV6='"${PUBLIC_IPV6}"'
47 | DISTRO='"${DISTRO}"'
48 | FIRST_TIME_SETUP='"${FIRST_TIME_SETUP}"'
49 | PRIVATE_IP='"${PRIVATE_IP}"'' | sudo -E tee /etc/yiimpool.conf >/dev/null 2>&1
50 |
51 | # Set Donor Addresses
52 | echo 'BTCDON="bc1q582gdvyp09038hp9n5sfdtp0plkx5x3yrhq05y"
53 | LTCDON="ltc1qqw7cv4snx9ctmpcf25x26lphqluly4w6m073qw"
54 | ETHDON="0x50C7d0BF9714dBEcDc1aa6Ab0E72af8e6Ce3b0aB"
55 | BCHDON="qzz0aff2k0xnwyzg7k9fcxlndtaj4wa65uxteqe84m"
56 | DOGEDON="DSzcmyCRi7JeN4XUiV2qYhRQAydNv7A1Yb"' | sudo -E tee /etc/yiimpooldonate.conf >/dev/null 2>&1
57 |
58 | cd ~
59 | sudo setfacl -m u:${whoami}:rwx /home/${whoami}/yiimp_install_script
60 | clear
61 | echo -e "$YELLOW Your User:$MAGENTA ${whoami}$YELLOW has been modified for yiimpool support. $COL_RESET"
62 | echo -e "$YELLOW You must$RED reboot$YELLOW the system for the new permissions to update and type$GREEN yiimpool$YELLOW to continue setup...$COL_RESET"
63 | exit 0
--------------------------------------------------------------------------------
/install/menu.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | #
4 | # This is the main menu
5 | #
6 | # Author: Afiniel
7 | #
8 | # Updated: 2023-03-16
9 | #
10 |
11 | source /etc/yiimpooldonate.conf
12 | source /etc/functions.sh
13 |
14 | RESULT=$(dialog --stdout --nocancel --default-item 1 --title "YiimPool Menu $VERSION" --menu "Choose an option" -1 55 7 \
15 | ' ' "- Install Yiimp -" \
16 | 1 "Yiimp Single Server" \
17 | ' ' "- Upgrade Yiimp Stratum -" \
18 | 2 "Upgrade Stratum" \
19 | 3 exit)
20 |
21 | if [ "$RESULT" = "1" ]; then
22 | clear;
23 | cd $HOME/yiimp_install_script/yiimp_single
24 | source start.sh
25 |
26 | elif [ "$RESULT" = "2" ]; then
27 | clear;
28 | cd $HOME/yiimp_install_script/yiimp_upgrade
29 | source start.sh
30 |
31 | elif [ "$RESULT" = "3" ]; then
32 | clear;
33 | exit;
34 | fi
--------------------------------------------------------------------------------
/install/pre_setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | ##################################################################################
4 | # This is the entry point for configuring the system. #
5 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox #
6 | # Updated by Afiniel for yiimpool use... #
7 | ##################################################################################
8 |
9 | source /etc/functions.sh
10 | clear
11 | echo -e "$YELLOW => Setting our global variables <= $COL_RESET"
12 |
13 | # If the machine is behind a NAT, inside a VM, etc., it may not know
14 | # its IP address on the public network / the Internet. Ask the Internet
15 | # and possibly confirm with user.
16 | if [ -z "${PUBLIC_IP:-}" ]; then
17 | # Ask the Internet.
18 | GUESSED_IP=$(get_publicip_from_web_service 4)
19 |
20 | # On the first run, if we got an answer from the Internet then don't
21 | # ask the user.
22 | if [[ -z "${DEFAULT_PUBLIC_IP:-}" && ! -z "$GUESSED_IP" ]]; then
23 | PUBLIC_IP=$GUESSED_IP
24 |
25 | # On later runs, if the previous value matches the guessed value then
26 | # don't ask the user either.
27 | elif [ "${DEFAULT_PUBLIC_IP:-}" == "$GUESSED_IP" ]; then
28 | PUBLIC_IP=$GUESSED_IP
29 | fi
30 |
31 | if [ -z "${PUBLIC_IP:-}" ]; then
32 | input_box "Public IP Address" \
33 | "Enter the public IP address of this machine, as given to you by your ISP.
34 | \n\nPublic IP address:" \
35 | "$DEFAULT_PUBLIC_IP" \
36 | PUBLIC_IP
37 |
38 | if [ -z "$PUBLIC_IP" ]; then
39 | # user hit ESC/cancel
40 | exit
41 | fi
42 | fi
43 | fi
44 |
45 | # Same for IPv6. But it's optional. Also, if it looks like the system
46 | # doesn't have an IPv6, don't ask for one.
47 | if [ -z "${PUBLIC_IPV6:-}" ]; then
48 | # Ask the Internet.
49 | GUESSED_IP=$(get_publicip_from_web_service 6)
50 | MATCHED=0
51 | if [[ -z "${DEFAULT_PUBLIC_IPV6:-}" && ! -z "$GUESSED_IP" ]]; then
52 | PUBLIC_IPV6=$GUESSED_IP
53 | elif [[ "${DEFAULT_PUBLIC_IPV6:-}" == "$GUESSED_IP" ]]; then
54 | # No IPv6 entered and machine seems to have none, or what
55 | # the user entered matches what the Internet tells us.
56 | PUBLIC_IPV6=$GUESSED_IP
57 | MATCHED=1
58 | elif [[ -z "${DEFAULT_PUBLIC_IPV6:-}" ]]; then
59 | DEFAULT_PUBLIC_IP=$(get_default_privateip 6)
60 | fi
61 |
62 | if [[ -z "${PUBLIC_IPV6:-}" && $MATCHED == 0 ]]; then
63 | input_box "IPv6 Address (Optional)" \
64 | "Enter the public IPv6 address of this machine, as given to you by your ISP.
65 | \n\nLeave blank if the machine does not have an IPv6 address.
66 | \n\nPublic IPv6 address:" \
67 | ${DEFAULT_PUBLIC_IPV6:-} \
68 | PUBLIC_IPV6
69 |
70 | if [ ! $PUBLIC_IPV6_EXITCODE ]; then
71 | # user hit ESC/cancel
72 | exit
73 | fi
74 | fi
75 | fi
76 |
77 | # Get the IP addresses of the local network interface(s) that are connected
78 | # to the Internet. We need these when we want to have services bind only to
79 | # the public network interfaces (not loopback, not tunnel interfaces).
80 | # if [ -z "$PRIVATE_IP" ]; then
81 | # DEFAULT_PRIVATE_IP=$(get_default_privateip 4)
82 | # input_box "Private IP Address (Optional)" \
83 | # "Enter the private IP address of this machine, as given to you by your ISP.
84 | # \n\nLeave as your public IP if the machine does not have a private IP address.
85 | # \n\nPrivate IP address:" \
86 | # $DEFAULT_PRIVATE_IP \
87 | # PRIVATE_IP
88 | #
89 | # if [ -z "$PRIVATE_IP" ]; then
90 | # user hit ESC/cancel
91 | # exit
92 | # fi
93 | # fi
94 |
95 | # Automatic configuration, e.g. as used in our Vagrant configuration.
96 | if [ "$PUBLIC_IP" = "auto" ]; then
97 | # Use a public API to get our public IP address, or fall back to local network configuration.
98 | PUBLIC_IP=$(get_publicip_from_web_service 4 || get_default_privateip 4)
99 | fi
100 | if [ "$PUBLIC_IPV6" = "auto" ]; then
101 | # Use a public API to get our public IPv6 address, or fall back to local network configuration.
102 | PUBLIC_IPV6=$(get_publicip_from_web_service 6 || get_default_privateip 6)
103 | fi
--------------------------------------------------------------------------------
/install/preflight.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | ##################################################################################
4 | # This is the entry point for configuring the system. #
5 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox #
6 | # Updated by Afiniel for yiimpool use... #
7 | ##################################################################################
8 | if [ "$(lsb_release -d | sed 's/.*:\s*//' | sed 's/20\.04\.[0-9]/20.04/')" == "Ubuntu 20.04 LTS" ]; then
9 | DISTRO=20
10 | sudo chmod g-w /etc /etc/default /usr
11 |
12 | elif [ "$(lsb_release -d | sed 's/.*:\s*//' | sed 's/18\.04\.[0-9]/18.04/')" == "Ubuntu 18.04 LTS" ]; then
13 | DISTRO=18
14 | sudo chmod g-w /etc /etc/default /usr
15 |
16 | elif [ "$(lsb_release -d | sed 's/.*:\s*//' | sed 's/16\.04\.[0-9]/16.04/')" == "Ubuntu 16.04 LTS" ]; then
17 | DISTRO=16
18 | sudo chmod g-w /etc /etc/default /usr
19 |
20 | else
21 | echo "This script only supports Ubuntu 16.04 LTS, 18.04 LTS, and 20.04 LTS."
22 | exit
23 | fi
24 |
25 | # Check if swap is needed.
26 |
27 | SWAP_MOUNTED=$(cat /proc/swaps | tail -n+2)
28 | SWAP_IN_FSTAB=$(grep "swap" /etc/fstab)
29 | ROOT_IS_BTRFS=$(grep "\/ .*btrfs" /proc/mounts)
30 | TOTAL_PHYSICAL_MEM=$(head -n 1 /proc/meminfo | awk '{print $2}')
31 | AVAILABLE_DISK_SPACE=$(df / --output=avail | tail -n 1)
32 | if
33 | [ -z "$SWAP_MOUNTED" ] &&
34 | [ -z "$SWAP_IN_FSTAB" ] &&
35 | [ ! -e /swapfile ] &&
36 | [ -z "$ROOT_IS_BTRFS" ] &&
37 | [ $TOTAL_PHYSICAL_MEM -lt 1536000 ] &&
38 | [ $AVAILABLE_DISK_SPACE -gt 5242880 ]
39 | then
40 | echo "Adding a swap file to the system..."
41 |
42 | # Allocate and activate the swap file. Allocate in 1KB chunks
43 | # doing it in one go could fail on low memory systems
44 | sudo fallocate -l 3G /swapfile
45 | if [ -e /swapfile ]; then
46 | sudo chmod 600 /swapfile
47 | sudo mkswap /swapfile
48 | sudo swapon /swapfile
49 | echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf
50 | fi
51 |
52 | # Check if swap is mounted then activate on boot
53 | if swapon -s | grep -q "\/swapfile"; then
54 | echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab
55 | else
56 | echo "ERROR: Swap allocation failed"
57 | fi
58 | fi
59 |
60 | ARCHITECTURE=$(uname -m)
61 | if [ "$ARCHITECTURE" != "x86_64" ]; then
62 | if [ -z "$ARM" ]; then
63 | echo "Yiimpool Installer only supports x86_64 and will not work on any other architecture, like ARM or 32-bit OS."
64 | echo "Your architecture is $ARCHITECTURE"
65 | exit
66 | fi
67 | fi
68 |
69 | # Set STORAGE_USER and STORAGE_ROOT to default values (crypto-data and /home/crypto-data), unless
70 | # we've already got those values from a previous run.
71 | if [ -z "$STORAGE_USER" ]; then
72 | STORAGE_USER=$([[ -z "$DEFAULT_STORAGE_USER" ]] && echo "crypto-data" || echo "$DEFAULT_STORAGE_USER")
73 | fi
74 | if [ -z "$STORAGE_ROOT" ]; then
75 | STORAGE_ROOT=$([[ -z "$DEFAULT_STORAGE_ROOT" ]] && echo "/home/$STORAGE_USER" || echo "$DEFAULT_STORAGE_ROOT")
76 | fi
77 |
--------------------------------------------------------------------------------
/install/start.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##################################################################################
4 | # This is the entry point for configuring the system. #
5 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox #
6 | # Updated by Afiniel for yiimpool use... #
7 | ##################################################################################
8 |
9 | # Recall the last settings used if we're running this a second time.
10 | if [ -f /etc/yiimpool.conf ]; then
11 | # Load the old .conf file to get existing configuration options loaded
12 | # into variables with a DEFAULT_ prefix.
13 | cat /etc/yiimpool.conf | sed s/^/DEFAULT_/ >/tmp/yiimpool.prev.conf
14 | source /tmp/yiimpool.prev.conf
15 | source /etc/yiimpooldonate.conf
16 | source /etc/yiimpoolversion.conf
17 | rm -f /tmp/yiimpool.prev.conf
18 | else
19 | FIRST_TIME_SETUP=1
20 | fi
21 |
22 | if [[ ("$FIRST_TIME_SETUP" == "1") ]]; then
23 | clear
24 | cd $HOME/yiimp_install_script/install
25 |
26 | # copy functions to /etc
27 | source functions.sh
28 | sudo cp -r functions.sh /etc/
29 | sudo cp -r editconf.py /usr/bin
30 | sudo chmod +x /usr/bin/editconf.py
31 |
32 | # Check system setup: Are we running as root on Ubuntu 16.04 on a
33 | # machine with enough memory?
34 | # If not, this shows an error and exits.
35 | source preflight.sh
36 |
37 | # Ensure Python reads/writes files in UTF-8. If the machine
38 | # triggers some other locale in Python, like ASCII encoding,
39 | # Python may not be able to read/write files. This is also
40 | # in the management daemon startup script and the cron script.
41 |
42 | if ! locale -a | grep en_US.utf8 >/dev/null; then
43 | # Generate locale if not exists
44 | hide_output locale-gen en_US.UTF-8
45 | fi
46 |
47 | export LANGUAGE=en_US.UTF-8
48 | export LC_ALL=en_US.UTF-8
49 | export LANG=en_US.UTF-8
50 | export LC_TYPE=en_US.UTF-8
51 |
52 | # Fix so line drawing characters are shown correctly in Putty on Windows. See #744.
53 | export NCURSES_NO_UTF8_ACS=1
54 |
55 | #check for user
56 | echo -e "$YELLOW => Installing needed packages for setup to$GREEN continue$YELLOW <= $COL_RESET"
57 | hide_output sudo apt-get -q -q update
58 | hide_output sudo apt-get install -y figlet
59 | hide_output sudo apt-get install -y lolcat
60 | apt_get_quiet install dialog python3 python3-pip acl nano git apt-transport-https || exit 1
61 |
62 | # Are we running as root?
63 | if [[ $EUID -ne 0 ]]; then
64 | # Welcome
65 | message_box "Yiimpool Installer $VERSION" \
66 | "Hello and thanks for using the Yiimpool Installer!
67 | \n\nInstallation for the most part is fully automated. In most cases any user responses that are needed are asked prior to the installation.
68 | \n\nNOTE: You should only install this on a brand new Ubuntu 20.04 , Ubuntu 18.04 or Ubuntu 16.04 installation."
69 | source existing_user.sh
70 | exit
71 | else
72 | source create_user.sh
73 | exit
74 | fi
75 | cd ~
76 |
77 | else
78 | clear
79 |
80 | # Ensure Python reads/writes files in UTF-8. If the machine
81 | # triggers some other locale in Python, like ASCII encoding,
82 | # Python may not be able to read/write files. This is also
83 | # in the management daemon startup script and the cron script.
84 |
85 | if ! locale -a | grep en_US.utf8 >/dev/null; then
86 | # Generate locale if not exists
87 | hide_output locale-gen en_US.UTF-8
88 | fi
89 |
90 | export LANGUAGE=en_US.UTF-8
91 | export LC_ALL=en_US.UTF-8
92 | export LANG=en_US.UTF-8
93 | export LC_TYPE=en_US.UTF-8
94 | # Fix so line drawing characters are shown correctly in Putty on Windows. See #744.
95 | export NCURSES_NO_UTF8_ACS=1
96 |
97 | # Load our functions and variables.
98 | source /etc/functions.sh
99 | source /etc/yiimpool.conf
100 | # Start yiimpool
101 | cd $HOME/yiimp_install_script/install
102 | source menu.sh
103 | cd ~
104 | fi
105 |
--------------------------------------------------------------------------------
/yiimp_single/compile_crypto.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##################################################################################
4 | # This is the entry point for configuring the system. #
5 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox #
6 | # Updated by Afiniel for yiimpool use... #
7 | ##################################################################################
8 |
9 | source /etc/functions.sh
10 | source /etc/yiimpool.conf
11 |
12 | set -eu -o pipefail
13 |
14 | function print_error {
15 | read line file <<<$(caller)
16 | echo "An error occurred in line $line of file $file:" >&2
17 | sed "${line}q;d" "$file" >&2
18 | }
19 | trap print_error ERR
20 | term_art
21 | echo -e "$MAGENTA <---------------------------------------->$COL_RESET"
22 | echo -e "$MAGENTA <--$YELLOW Install DaemonBuilder Requirements$MAGENTA -->$COL_RESET"
23 | echo -e "$MAGENTA <---------------------------------------->$COL_RESET"
24 |
25 | cd $HOME/yiimp_install_script/daemon_builder
26 | source start.sh
27 |
28 | set +eu +o pipefail
29 | cd $HOME/yiimp_install_script/yiimp_single
--------------------------------------------------------------------------------
/yiimp_single/daemon.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##########################################
4 | # Created by Afiniel for Yiimpool use... #
5 | ##########################################
6 |
7 | source /etc/functions.sh
8 | source /etc/yiimpool.conf
9 | source $STORAGE_ROOT/yiimp/.yiimp.conf
10 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
11 |
12 | set -eu -o pipefail
13 |
14 | function print_error {
15 | read line file <<<$(caller)
16 | echo "An error occurred in line $line of file $file:" >&2
17 | sed "${line}q;d" "$file" >&2
18 | }
19 | trap print_error ERR
20 | term_art
21 | echo -e "$MAGENTA <----------------------------------------------------->$COL_RESET"
22 | echo -e "$MAGENTA <--$YELLOW Installing Berkeley , openssl , bls-signatures$MAGENTA -->$COL_RESET"
23 | echo -e "$MAGENTA <----------------------------------------------------->$COL_RESET"
24 | echo
25 |
26 | echo -e "$YELLOW => Installing BitCoin PPA <= $COL_RESET"
27 | if [ ! -f /etc/apt/sources.list.d/bitcoin.list ]; then
28 | hide_output sudo add-apt-repository -y ppa:bitcoin/bitcoin
29 | fi
30 | echo
31 | echo -e "$YELLOW => Installing additional system files required for daemons <= $COL_RESET"
32 | hide_output sudo apt-get update
33 | apt_install build-essential libtool autotools-dev \
34 | automake pkg-config libssl-dev libevent-dev bsdmainutils git libboost-all-dev libminiupnpc-dev \
35 | libqt5gui5 libqt5core5a libqt5webkit5-dev libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev \
36 | protobuf-compiler libqrencode-dev libzmq3-dev libgmp-dev
37 |
38 | sudo mkdir -p $STORAGE_ROOT/yiimp/yiimp_setup/tmp
39 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
40 | echo
41 | echo -e "$GREEN => Additional System Files Completed <= $COL_RESET"
42 |
43 | echo
44 | echo -e "$MAGENTA => Building Berkeley 4.8, this may take several minutes <= $COL_RESET"
45 | sudo mkdir -p $STORAGE_ROOT/berkeley/db4/
46 | hide_output sudo wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
47 | hide_output sudo tar -xzvf db-4.8.30.NC.tar.gz
48 | cd db-4.8.30.NC/build_unix/
49 | hide_output sudo ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$STORAGE_ROOT/berkeley/db4/
50 | hide_output sudo make -j$((`nproc`+1))
51 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
52 | sudo rm -r db-4.8.30.NC.tar.gz db-4.8.30.NC
53 | echo
54 | echo -e "$GREEN => Berkeley 4.8 Completed <= $COL_RESET"
55 | echo
56 |
57 | echo -e "$MAGENTA => Building Berkeley 5.1, this may take several minutes <= $COL_RESET"
58 | echo
59 | sudo mkdir -p $STORAGE_ROOT/berkeley/db5/
60 | hide_output sudo wget 'http://download.oracle.com/berkeley-db/db-5.1.29.tar.gz'
61 | hide_output sudo tar -xzvf db-5.1.29.tar.gz
62 | cd db-5.1.29/build_unix/
63 | hide_output sudo ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$STORAGE_ROOT/berkeley/db5/
64 | hide_output sudo make -j$((`nproc`+1))
65 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
66 | sudo rm -r db-5.1.29.tar.gz db-5.1.29
67 | echo -e "$GREEN => Berkeley 5.1 Completed <= $COL_RESET"
68 | echo
69 | echo -e "$MAGENTA => Building Berkeley 5.3, this may take several minutes <= $COL_RESET"
70 | echo
71 | sudo mkdir -p $STORAGE_ROOT/berkeley/db5.3/
72 | hide_output sudo wget 'http://anduin.linuxfromscratch.org/BLFS/bdb/db-5.3.28.tar.gz'
73 | hide_output sudo tar -xzvf db-5.3.28.tar.gz
74 | cd db-5.3.28/build_unix/
75 | hide_output sudo ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$STORAGE_ROOT/berkeley/db5.3/
76 | hide_output sudo make -j$((`nproc`+1))
77 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
78 | sudo rm -r db-5.3.28.tar.gz db-5.3.28
79 | echo -e "$GREEN => Berkeley 5.3 Completed <= $COL_RESET"
80 | echo
81 | echo -e "$YELLOW Building Berkeley 6.2, this may take several minutes...$COL_RESET"
82 | echo
83 | sudo mkdir -p $STORAGE_ROOT/berkeley/db6.2/
84 | hide_output sudo wget 'https://download.oracle.com/berkeley-db/db-6.2.23.tar.gz'
85 | hide_output sudo tar -xzvf db-6.2.23.tar.gz
86 | cd db-6.2.23/build_unix/
87 | hide_output sudo ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$STORAGE_ROOT/berkeley/db6.2/
88 | hide_output sudo make -j$((`nproc`+1))
89 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
90 | sudo rm -r db-6.2.23.tar.gz db-6.2.23
91 | echo -e "$GREEN => Berkeley 6.2 Completed <= $COL_RESET"
92 | echo
93 | echo -e "$YELLOW Building Berkeley 18, this may take several minutes...$COL_RESET"
94 | echo
95 | sudo mkdir -p $STORAGE_ROOT/berkeley/db18/
96 | hide_output sudo wget 'https://download.oracle.com/berkeley-db/db-18.1.40.tar.gz'
97 | hide_output sudo tar -xzvf db-18.1.40.tar.gz
98 | cd db-18.1.40/build_unix/
99 | hide_output sudo ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$STORAGE_ROOT/berkeley/db18/
100 | hide_output sudo make -j$((`nproc`+1))
101 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
102 | sudo rm -r db-18.1.40.tar.gz db-18.1.40
103 | echo -e "$GREEN => Berkeley 18 Completed <= $COL_RESET"
104 | echo
105 |
106 | echo -e "$YELLOW => Building OpenSSL 1.0.2g, this may take several minutes <= $COL_RESET"
107 | echo
108 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
109 | hide_output sudo wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2g.tar.gz --no-check-certificate
110 | hide_output sudo tar -xf openssl-1.0.2g.tar.gz
111 | cd openssl-1.0.2g
112 | hide_output sudo ./config --prefix=$STORAGE_ROOT/openssl --openssldir=$STORAGE_ROOT/openssl shared zlib
113 | hide_output sudo make -j$((`nproc`+1))
114 | hide_output sudo make install -j$((`nproc`+1))
115 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
116 | sudo rm -r openssl-1.0.2g.tar.gz openssl-1.0.2g
117 | echo -e "$GREEN =>OpenSSL 1.0.2g Completed <= $COL_RESET"
118 | echo
119 |
120 | echo -e "$YELLOW => Building bls-signatures, this may take several minutes <= $COL_RESET"
121 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
122 | hide_output sudo wget 'https://github.com/codablock/bls-signatures/archive/v20181101.zip'
123 | hide_output sudo unzip v20181101.zip
124 | cd bls-signatures-20181101
125 | hide_output sudo cmake .
126 | hide_output sudo make install -j$((`nproc`+1))
127 | cd $STORAGE_ROOT/yiimp/yiimp_setup/tmp
128 | sudo rm -r v20181101.zip bls-signatures-20181101
129 | echo
130 | echo -e "$GREEN => bls-signatures Completed$COL_RESET"
131 |
132 | echo
133 | echo -e "$YELLOW => Building blocknotify.sh <= $COL_RESET"
134 | if [[ ("$wireguard" == "true") ]]; then
135 | source $STORAGE_ROOT/yiimp/.wireguard.conf
136 | echo '#####################################
137 | # Created by Afiniel for Yiimpool use... #
138 | ###########################################
139 | #!/bin/bash
140 | blocknotify '""''"${DBInternalIP}"''""':$1 $2 $3' | sudo -E tee /usr/bin/blocknotify.sh >/dev/null 2>&1
141 | sudo chmod +x /usr/bin/blocknotify.sh
142 | else
143 | echo '#####################################
144 | # Created by Afiniel for Yiimpool use... #
145 | ###########################################
146 | #!/bin/bash
147 | blocknotify 127.0.0.1:$1 $2 $3' | sudo -E tee /usr/bin/blocknotify.sh >/dev/null 2>&1
148 | sudo chmod +x /usr/bin/blocknotify.sh
149 | fi
150 |
151 | echo
152 | echo -e "$GREEN Daemon setup completed $COL_RESET"
153 |
154 | set +eu +o pipefail
155 | cd $HOME/yiimp_install_script/yiimp_single
156 |
--------------------------------------------------------------------------------
/yiimp_single/db.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Created by Afiniel for Yiimpool use...
5 | #####################################################
6 |
7 | source /etc/functions.sh
8 | source /etc/yiimpoolversion.conf
9 | source /etc/yiimpool.conf
10 | source $STORAGE_ROOT/yiimp/.yiimp.conf
11 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
12 |
13 | set -eu -o pipefail
14 |
15 | function print_error {
16 | read line file <<<$(caller)
17 | echo "An error occurred in line $line of file $file:" >&2
18 | sed "${line}q;d" "$file" >&2
19 | }
20 | trap print_error ERR
21 | term_art
22 | if [[ ("$wireguard" == "true") ]]; then
23 | source $STORAGE_ROOT/yiimp/.wireguard.conf
24 | fi
25 |
26 | # Define MariaDB version
27 | MARIADB_VERSION='10.4'
28 |
29 | echo -e "$MAGENTA <----------------------------->$COL_RESET"
30 | echo -e "$MAGENTA <--$YELLOW Installing MariaDB$MAGENTA $MARIADB_VERSION -->$COL_RESET"
31 | echo -e "$MAGENTA <----------------------------->$COL_RESET"
32 | echo
33 | # Set MariaDB root password for installation
34 | sudo debconf-set-selections <<<"maria-db-$MARIADB_VERSION mysql-server/root_password password $DBRootPassword"
35 | sudo debconf-set-selections <<<"maria-db-$MARIADB_VERSION mysql-server/root_password_again password $DBRootPassword"
36 |
37 | # Install MariaDB
38 | apt_install mariadb-server mariadb-client
39 |
40 | # Display completion message
41 | echo -e "$GREEN => MariaDB build complete <= $COL_RESET"
42 | echo
43 |
44 | # Display message for creating DB users
45 | echo -e "$MAGENTA => Creating DB users for YiiMP <= $COL_RESET"
46 | echo
47 | # Check if wireguard variable is set to false
48 | if [ "$wireguard" = "false" ]; then
49 | # Define SQL statements
50 | Q1="CREATE DATABASE IF NOT EXISTS ${YiiMPDBName};"
51 | Q2="GRANT ALL ON ${YiiMPDBName}.* TO '${YiiMPPanelName}'@'localhost' IDENTIFIED BY '$PanelUserDBPassword';"
52 | Q3="GRANT ALL ON ${YiiMPDBName}.* TO '${StratumDBUser}'@'localhost' IDENTIFIED BY '$StratumUserDBPassword';"
53 | Q4="FLUSH PRIVILEGES;"
54 | SQL="${Q1}${Q2}${Q3}${Q4}"
55 | # Run SQL statements
56 | sudo mysql -u root -p"${DBRootPassword}" -e "$SQL"
57 |
58 | else
59 | # Define SQL statements
60 | Q1="CREATE DATABASE IF NOT EXISTS ${YiiMPDBName};"
61 | Q2="GRANT ALL ON ${YiiMPDBName}.* TO '${YiiMPPanelName}'@'${DBInternalIP}' IDENTIFIED BY '$PanelUserDBPassword';"
62 | Q3="GRANT ALL ON ${YiiMPDBName}.* TO '${StratumDBUser}'@'${DBInternalIP}' IDENTIFIED BY '$StratumUserDBPassword';"
63 | Q4="FLUSH PRIVILEGES;"
64 | SQL="${Q1}${Q2}${Q3}${Q4}"
65 | # Run SQL statements
66 | sudo mysql -u root -p"${DBRootPassword}" -e "$SQL"
67 | fi
68 |
69 | echo
70 | echo -e "$MAGENTA => Creating my.cnf <= $COL_RESET"
71 |
72 | if [[ ("$wireguard" == "false") ]]; then
73 | echo '[clienthost1]
74 | user='"${YiiMPPanelName}"'
75 | password='"${PanelUserDBPassword}"'
76 | database='"${YiiMPDBName}"'
77 | host=localhost
78 | [clienthost2]
79 | user='"${StratumDBUser}"'
80 | password='"${StratumUserDBPassword}"'
81 | database='"${YiiMPDBName}"'
82 | host=localhost
83 | [mysql]
84 | user=root
85 | password='"${DBRootPassword}"'
86 | ' | sudo -E tee $STORAGE_ROOT/yiimp/.my.cnf >/dev/null 2>&1
87 |
88 | else
89 | echo '[clienthost1]
90 | user='"${YiiMPPanelName}"'
91 | password='"${PanelUserDBPassword}"'
92 | database='"${YiiMPDBName}"'
93 | host='"${DBInternalIP}"'
94 | [clienthost2]
95 | user='"${StratumDBUser}"'
96 | password='"${StratumUserDBPassword}"'
97 | database='"${YiiMPDBName}"'
98 | host='"${DBInternalIP}"'
99 | [mysql]
100 | user=root
101 | password='"${DBRootPassword}"'
102 | ' | sudo -E tee $STORAGE_ROOT/yiimp/.my.cnf >/dev/null 2>&1
103 | fi
104 |
105 | sudo chmod 0600 $STORAGE_ROOT/yiimp/.my.cnf
106 |
107 | echo
108 | echo -e "$YELLOW => Importing YiiMP Default database values <= $COL_RESET"
109 | cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/sql
110 |
111 | # import SQL dump
112 | sudo zcat 2020-11-10-yaamp.sql.gz | sudo mysql -u root -p"${DBRootPassword}" "${YiiMPDBName}"
113 |
114 | SQL_FILES=(
115 | 2016-04-24-market_history.sql
116 | 2016-04-27-settings.sql
117 | 2016-05-11-coins.sql
118 | 2016-05-15-benchmarks.sql
119 | 2016-05-23-bookmarks.sql
120 | 2016-06-01-notifications.sql
121 | 2016-06-04-bench_chips.sql
122 | 2016-11-23-coins.sql
123 | 2017-02-05-benchmarks.sql
124 | 2017-03-31-earnings_index.sql
125 | 2017-05-accounts_case_swaptime.sql
126 | 2017-06-payouts_coinid_memo.sql
127 | 2017-09-notifications.sql
128 | 2017-10-bookmarks.sql
129 | 2017-11-segwit.sql
130 | 2018-01-stratums_ports.sql
131 | 2018-02-coins_getinfo.sql
132 | 2018-09-22-workers.sql
133 | 2019-03-coins_thepool_life.sql
134 | 2020-06-03-blocks.sql
135 | 2022-10-14-shares_solo.sql
136 | 2022-10-29-blocks_effort.sql
137 | )
138 |
139 | for file in "${SQL_FILES[@]}"; do
140 | sudo mysql -u root -p"${DBRootPassword}" "${YiiMPDBName}" --force < "$file"
141 | done
142 |
143 | echo
144 | echo -e "$YELLOW <-- Datebase import $GREEN complete -->$COL_RESET"
145 |
146 | echo
147 | echo -e "$YELLOW => Tweaking MariaDB for better performance <= $COL_RESET"
148 |
149 | # Define MariaDB configuration changes
150 | config_changes=(
151 | 'max_connections = 800'
152 | 'thread_cache_size = 512'
153 | 'tmp_table_size = 128M'
154 | 'max_heap_table_size = 128M'
155 | 'wait_timeout = 60'
156 | 'max_allowed_packet = 64M'
157 | )
158 |
159 | # Add bind-address if wireguard is true.
160 | if [[ "$wireguard" == "true" ]]; then
161 | config_changes+=("bind-address=$DBInternalIP")
162 | fi
163 |
164 | # Prepare the configuration changes as a string with each option on a separate line
165 | config_string=$(printf "%s\n" "${config_changes[@]}")
166 |
167 | # Apply changes to MariaDB configuration
168 | sudo bash -c "echo \"$config_string\" >> /etc/mysql/my.cnf"
169 |
170 | # Restart MariaDB
171 | restart_service mysql
172 |
173 | set +eu +o pipefail
174 | cd $HOME/yiimp_install_script/yiimp_single
--------------------------------------------------------------------------------
/yiimp_single/first_boot.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Created by Afiniel for Yiimpool use...
5 | #####################################################
6 | # Needs to be ran after the first reboot of the system after permissions are set
7 | #####################################################
8 |
9 | source /etc/yiimpool.conf
10 | source /etc/functions.sh
11 |
12 | sleep 5
13 | hide_output yiimp checkup
14 |
15 | # Prevents error when trying to log in to admin panel the first time...
16 |
17 | sudo touch $STORAGE_ROOT/yiimp/site/log/debug.log
18 | sudo chmod 777 $STORAGE_ROOT/yiimp/site/log/.
19 | sudo chmod 777 $STORAGE_ROOT/yiimp/site/log/debug.log
20 |
21 | # Delete me no longer needed after it runs the first time
22 |
23 | sudo rm -r $STORAGE_ROOT/yiimp/first_boot.sh
24 | cd $HOME/yiimp_install_script/yiimp_single
25 |
--------------------------------------------------------------------------------
/yiimp_single/menu.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | #
4 | # This is the main menu
5 | #
6 | # Author: Afiniel
7 | #
8 | # Updated: 2023-03-16
9 | #
10 |
11 | source /etc/yiimpooldonate.conf
12 | source /etc/functions.sh
13 |
14 | RESULT=$(dialog --stdout --default-item 1 --title "YiimPool Yiimp Installer $VERSION" --menu "choose an option" -1 55 7 \
15 | ' ' "- Do you want to install Yiimp with whireguard? -" \
16 | 1 "Yes" \
17 | 2 "No" \
18 | 3 exit)
19 |
20 | if [ "$RESULT" = "1" ]; then
21 | clear;
22 | echo '
23 | wireguard=true
24 | ' | sudo -E tee "$HOME"/yiimp_install_script/yiimp_single/.wireguard.install.cnf >/dev/null 2>&1;
25 |
26 |
27 | elif [ "$RESULT" = "2" ]; then
28 | clear;
29 | echo '
30 | wireguard=false
31 | ' | sudo -E tee "$HOME"/yiimp_install_script/yiimp_single/.wireguard.install.cnf >/dev/null 2>&1;
32 |
33 |
34 | elif [ "$RESULT" = "3" ]; then
35 | clear;
36 | exit;
37 | fi
38 |
--------------------------------------------------------------------------------
/yiimp_single/motd.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Created by Afiniel for Yiimpool use...
5 | #####################################################
6 |
7 | source /etc/functions.sh # load our functions
8 | source /etc/yiimpool.conf
9 |
10 | apt_install lsb-release figlet update-motd \
11 | landscape-common update-notifier-common
12 | cd $HOME/yiimp_install_script/yiimp_single/ubuntu/etc/update-motd.d
13 | sudo rm -r /etc/update-motd.d/
14 | sudo mkdir /etc/update-motd.d/
15 | sudo touch /etc/update-motd.d/00-header
16 | sudo touch /etc/update-motd.d/10-sysinfo
17 | sudo touch /etc/update-motd.d/90-footer
18 | sudo chmod +x /etc/update-motd.d/*
19 | sudo cp -r 00-header 10-sysinfo 90-footer /etc/update-motd.d/
20 |
21 | # copy additional files
22 | cd $HOME/yiimp_install_script/yiimp_single/ubuntu/
23 | sudo cp -r screens /usr/bin/
24 | sudo chmod +x /usr/bin/screens
25 | sudo cp -r stratum /usr/bin
26 | sudo chmod +x /usr/bin/stratum
27 | echo '
28 | clear
29 | run-parts /etc/update-motd.d/ | sudo tee /etc/motd
30 | ' | sudo -E tee /usr/bin/motd >/dev/null 2>&1
31 |
32 | sudo chmod +x /usr/bin/motd
33 | cd $HOME/yiimp_install_script/yiimp_single
34 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_confs/general.conf:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Source Generated by nginxconfig.io
3 | # Updated by afiniel for crypto use...
4 | #####################################################
5 |
6 | # favicon.ico
7 | location = /favicon.ico {
8 | log_not_found off;
9 | access_log off;
10 | }
11 |
12 | # robots.txt
13 | location = /robots.txt {
14 | log_not_found off;
15 | access_log off;
16 | }
17 |
18 | # assets, media
19 | location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
20 | expires 7d;
21 | access_log off;
22 | }
23 |
24 | # svg, fonts
25 | location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
26 | add_header Access-Control-Allow-Origin "*";
27 | expires 7d;
28 | access_log off;
29 | }
30 |
31 | # gzip
32 | gzip on;
33 | gzip_vary on;
34 | gzip_proxied any;
35 | gzip_comp_level 6;
36 | gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
37 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_confs/letsencrypt.conf:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Source Generated by nginxconfig.io
3 | # Updated by afiniel for crypto use...
4 | #####################################################
5 |
6 | # ACME-challenge
7 | location ^~ /.well-known/acme-challenge/ {
8 | root /var/www/_letsencrypt;
9 | }
10 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_confs/nginx.conf:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Source Generated by nginxconfig.io
3 | # Updated by afiniel for crypto use...
4 | #####################################################
5 |
6 | user www-data;
7 | pid /run/nginx.pid;
8 | worker_processes auto;
9 | worker_rlimit_nofile 65535;
10 |
11 | events {
12 | multi_accept on;
13 | worker_connections 65535;
14 | }
15 |
16 | http {
17 | charset utf-8;
18 | sendfile on;
19 | tcp_nopush on;
20 | tcp_nodelay on;
21 | server_tokens off;
22 | log_not_found off;
23 | types_hash_max_size 2048;
24 | client_max_body_size 16M;
25 |
26 | # MIME
27 | include mime.types;
28 | default_type application/octet-stream;
29 |
30 | # logging
31 | access_log /var/log/nginx/access.log;
32 | error_log /var/log/nginx/error.log warn;
33 |
34 | # SSL
35 | ssl_session_timeout 1d;
36 | ssl_session_cache shared:SSL:10m;
37 | ssl_session_tickets off;
38 |
39 | # Diffie-Hellman parameter for DHE ciphersuites
40 | ssl_dhparam /etc/nginx/dhparam.pem;
41 |
42 | # Mozilla Intermediate configuration
43 | ssl_protocols TLSv1.2 TLSv1.3;
44 | ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
45 |
46 | # OCSP Stapling
47 | ssl_stapling on;
48 | ssl_stapling_verify on;
49 | resolver 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 valid=60s;
50 | resolver_timeout 2s;
51 |
52 | # load configs
53 | include /etc/nginx/conf.d/*.conf;
54 | include /etc/nginx/sites-enabled/*;
55 | }
56 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_confs/php_fastcgi.conf:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Source Generated by nginxconfig.io
3 | # Updated by afiniel for crypto use...
4 | #####################################################
5 |
6 | # 404
7 | try_files $uri $uri/ =404;
8 |
9 | # default fastcgi_params
10 | include fastcgi_params;
11 |
12 | # fastcgi settings
13 | fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
14 | fastcgi_index index.php;
15 | fastcgi_buffers 8 16k;
16 | fastcgi_buffer_size 32k;
17 | fastcgi_connect_timeout 300;
18 | fastcgi_send_timeout 300;
19 | fastcgi_read_timeout 300;
20 |
21 | # fastcgi params
22 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
23 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_confs/security.conf:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Source Generated by nginxconfig.io
3 | # Updated by afiniel for crypto use...
4 | #####################################################
5 |
6 | # security headers
7 | add_header X-Frame-Options "SAMEORIGIN" always;
8 | add_header X-XSS-Protection "1; mode=block" always;
9 | add_header X-Content-Type-Options "nosniff" always;
10 | add_header Referrer-Policy "no-referrer-when-downgrade" always;
11 | add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
12 | add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
13 |
14 | # . files
15 | location ~ /\.(?!well-known) {
16 | deny all;
17 | }
18 |
19 | location ~ \.sh {
20 | return 404;
21 | }
22 |
23 | location ~ /\.ht {
24 | deny all;
25 | }
26 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_confs/site.conf:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Source Generated by nginxconfig.io
3 | # Updated by afiniel for crypto use...
4 | #####################################################
5 |
6 | # NGINX Simple DDoS Defense
7 | limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
8 | limit_conn conn_limit_per_ip 80;
9 | limit_req zone=req_limit_per_ip burst=80 nodelay;
10 | limit_req_zone $binary_remote_addr zone=req_limit_per_ip:40m rate=5r/s;
11 |
12 | server {
13 | listen 443 ssl http2;
14 | listen [::]:443 ssl http2;
15 |
16 | server_name www.'"${DomainName}"';
17 | set $base "/var/www/'"${DomainName}"'/html";
18 | root $base/web;
19 |
20 | # SSL
21 | ssl_certificate /etc/letsencrypt/live/'"${DomainName}"'/fullchain.pem;
22 | ssl_certificate_key /etc/letsencrypt/live/'"${DomainName}"'/privkey.pem;
23 | ssl_trusted_certificate /etc/letsencrypt/live/'"${DomainName}"'/chain.pem;
24 |
25 | # security
26 | include yiimpool/security.conf;
27 |
28 | # logging
29 | access_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.access.log;
30 | error_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.error.log warn;
31 |
32 | # index.php
33 | index index.php;
34 |
35 | # index.php fallback
36 |
37 | location / {
38 | try_files $uri $uri/ /index.php?$args;
39 | }
40 | location @rewrite {
41 | rewrite ^/(.*)$ /index.php?r=$1;
42 | }
43 |
44 | # handle .php
45 | location ~ \.php$ {
46 | include yiimpool/php_fastcgi.conf;
47 | }
48 |
49 | # additional config
50 | include yiimpool/general.conf;
51 | }
52 |
53 | # non-www, subdomains redirect
54 | server {
55 | listen 443 ssl http2;
56 | listen [::]:443 ssl http2;
57 |
58 | server_name '"${DomainName}"';
59 |
60 | # SSL
61 | ssl_certificate /etc/letsencrypt/live/'"${DomainName}"'/fullchain.pem;
62 | ssl_certificate_key /etc/letsencrypt/live/'"${DomainName}"'/privkey.pem;
63 | ssl_trusted_certificate /etc/letsencrypt/live/'"${DomainName}"'/chain.pem;
64 |
65 | return 301 https://www.'"${DomainName}"'$request_uri;
66 | }
67 |
68 | # HTTP redirect
69 | server {
70 | listen 80;
71 | listen [::]:80;
72 |
73 | server_name .'"${DomainName}"';
74 |
75 | include yiimpool/letsencrypt.conf;
76 |
77 | location / {
78 | return 301 https://www.'"${DomainName}"'$request_uri;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_confs/site_self_ssl.conf:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Source Generated by nginxconfig.io
3 | # Updated by afiniel for crypto use...
4 | #####################################################
5 |
6 | # NGINX Simple DDoS Defense
7 | limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
8 | limit_conn conn_limit_per_ip 80;
9 | limit_req zone=req_limit_per_ip burst=80 nodelay;
10 | limit_req_zone $binary_remote_addr zone=req_limit_per_ip:40m rate=5r/s;
11 |
12 | server {
13 | listen 443 ssl http2;
14 | listen [::]:443 ssl http2;
15 |
16 | server_name www.'"${DomainName}"';
17 | set $base "/var/www/'"${DomainName}"'/html";
18 | root $base/web;
19 |
20 | # SSL
21 | ssl_certificate '"${STORAGE_ROOT}"'/ssl/ssl_certificate.pem;
22 | ssl_certificate_key '"${STORAGE_ROOT}"'/ssl/ssl_private_key.pem;
23 |
24 | # security
25 | include yiimpool/security.conf;
26 |
27 | # logging
28 | access_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.access.log;
29 | error_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.error.log warn;
30 |
31 | # index.php
32 | index index.php;
33 |
34 | # index.php fallback
35 | location / {
36 | try_files $uri $uri/ /index.php?$query_string;
37 | }
38 |
39 | # handle .php
40 | location ~ \.php$ {
41 | include yiimpool/php_fastcgi.conf;
42 | }
43 |
44 | # additional config
45 | include yiimpool/general.conf;
46 | }
47 |
48 | # non-www, subdomains redirect
49 | server {
50 | listen 443 ssl http2;
51 | listen [::]:443 ssl http2;
52 |
53 | server_name '"${DomainName}"';
54 |
55 | # SSL
56 | ssl_certificate /etc/letsencrypt/live/'"${DomainName}"'/fullchain.pem;
57 | ssl_certificate_key /etc/letsencrypt/live/'"${DomainName}"'/privkey.pem;
58 | ssl_trusted_certificate /etc/letsencrypt/live/'"${DomainName}"'/chain.pem;
59 |
60 | return 301 https://www.'"${DomainName}"'$request_uri;
61 | }
62 |
63 | # HTTP redirect
64 | server {
65 | listen 80;
66 | listen [::]:80;
67 |
68 | server_name .'"${DomainName}"';
69 |
70 | include yiimpool/letsencrypt.conf;
71 |
72 | location / {
73 | return 301 https://www.'"${DomainName}"'$request_uri;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_confs/ssl_nginx_default.conf:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Source https://www.nginx.com/
3 | # Updated by afiniel for crypto use...
4 | #####################################################
5 |
6 | echo 'include /etc/nginx/blockuseragents.rules;
7 | server {
8 | if ($blockedagent) {
9 | return 403;
10 | }
11 | if ($request_method !~ ^(GET|HEAD|POST)$) {
12 | return 444;
13 | }
14 | listen 80;
15 | listen [::]:80;
16 | server_name '"${DomainName}"';
17 | # enforce https
18 | return 301 https://$server_name$request_uri;
19 | }
20 |
21 | server {
22 | if ($blockedagent) {
23 | return 403;
24 | }
25 | if ($request_method !~ ^(GET|HEAD|POST)$) {
26 | return 444;
27 | }
28 | listen 443 ssl http2;
29 | listen [::]:443 ssl http2;
30 | server_name '"${DomainName}"';
31 |
32 | root /var/www/'"${DomainName}"'/html/web;
33 | index index.php;
34 | charset utf-8;
35 | location / {
36 | try_files $uri $uri/ /index.php?$args;
37 | }
38 | location @rewrite {
39 | rewrite ^/(.*)$ /index.php?r=$1;
40 | }
41 |
42 | location = /favicon.ico { access_log off; log_not_found off; }
43 | location = /robots.txt { access_log off; log_not_found off; }
44 |
45 | # to boost I/O on HDD we can disable access logs
46 | access_log off;
47 | error_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app-error.log error;
48 |
49 | # NGINX Simple DDoS Defense
50 | # limit the number of connections per single IP
51 | limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
52 |
53 | # limit the number of requests for a given session
54 | limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s;
55 |
56 | # zone which we want to limit by upper values, we want limit whole server
57 | server {
58 | limit_conn conn_limit_per_ip 10;
59 | limit_req zone=req_limit_per_ip burst=10 nodelay;
60 | }
61 |
62 | # if the request body size is more than the buffer size, then the entire (or partial)
63 | # request body is written into a temporary file
64 | client_body_buffer_size 128k;
65 |
66 | # headerbuffer size for the request header from client -- for testing environment
67 | client_header_buffer_size 3m;
68 |
69 | # maximum number and size of buffers for large headers to read from client request
70 | large_client_header_buffers 4 256k;
71 |
72 | # read timeout for the request body from client -- for testing environment
73 | client_body_timeout 3m;
74 |
75 | # how long to wait for the client to send a request header -- for testing environment
76 | client_header_timeout 3m;
77 |
78 | # copies data between one FD and other from within the kernel
79 | # faster then read() + write()
80 | sendfile on;
81 |
82 | # send headers in one peace, its better then sending them one by one
83 | tcp_nopush on;
84 |
85 | # don't buffer data sent, good for small data bursts in real time
86 | tcp_nodelay on;
87 |
88 | # allow the server to close connection on non responding client, this will free up memory
89 | reset_timedout_connection on;
90 |
91 | # request timed out -- default 60
92 | client_body_timeout 10;
93 |
94 | # if client stop responding, free up memory -- default 60
95 | send_timeout 2;
96 |
97 | # server will close connection after this time -- default 75
98 | keepalive_timeout 30;
99 |
100 | # strengthen ssl security
101 | ssl_certificate /etc/letsencrypt/live/'"${DomainName}"'/fullchain.pem;
102 | ssl_certificate_key /etc/letsencrypt/live/'"${DomainName}"'/privkey.pem;
103 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
104 | ssl_prefer_server_ciphers on;
105 | ssl_session_cache shared:SSL:10m;
106 | ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
107 | ssl_dhparam /etc/ssl/certs/dhparam.pem;
108 |
109 | # Add headers to serve security related headers
110 | add_header Strict-Transport-Security "max-age=15768000; preload;";
111 | add_header X-Content-Type-Options nosniff;
112 | add_header X-XSS-Protection "1; mode=block";
113 | add_header X-Robots-Tag none;
114 | add_header Content-Security-Policy "frame-ancestors 'self'";
115 |
116 | location ~ ^/index\.php$ {
117 | fastcgi_split_path_info ^(.+\.php)(/.+)$;
118 | fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
119 | fastcgi_index index.php;
120 | include fastcgi_params;
121 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
122 | fastcgi_intercept_errors off;
123 | fastcgi_buffer_size 16k;
124 | fastcgi_buffers 4 16k;
125 | fastcgi_connect_timeout 300;
126 | fastcgi_send_timeout 300;
127 | fastcgi_read_timeout 300;
128 | include /etc/nginx/fastcgi_params;
129 | try_files $uri $uri/ =404;
130 | }
131 | location ~ \.php$ {
132 | return 404;
133 | }
134 | location ~ \.sh {
135 | return 404;
136 | }
137 |
138 | location ~ /\.ht {
139 | deny all;
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_confs/web_default.conf:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Source https://www.nginx.com/
3 | # Updated by afiniel for crypto use...
4 | #####################################################
5 |
6 | echo 'include /etc/nginx/blockuseragents.rules;
7 | server {
8 | if ($blockedagent) {
9 | return 403;
10 | }
11 | if ($request_method !~ ^(GET|HEAD|POST)$) {
12 | return 444;
13 | }
14 | listen 80;
15 | listen [::]:80;
16 | server_name '"${DomainName}"';
17 | root "/var/www/'"${DomainName}"'/html/web";
18 | index index.php;
19 | charset utf-8;
20 |
21 | location / {
22 | try_files $uri $uri/ /index.php?$args;
23 | }
24 | location @rewrite {
25 | rewrite ^/(.*)$ /index.php?r=$1;
26 | }
27 |
28 | location = /favicon.ico { access_log off; log_not_found off; }
29 | location = /robots.txt { access_log off; log_not_found off; }
30 |
31 | # to boost I/O on HDD we can disable access logs
32 | access_log off;
33 | error_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app-error.log error;
34 |
35 | # NGINX Simple DDoS Defense
36 | # limit the number of connections per single IP
37 | limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
38 |
39 | # limit the number of requests for a given session
40 | limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s;
41 |
42 | # zone which we want to limit by upper values, we want limit whole server
43 | server {
44 | limit_conn conn_limit_per_ip 10;
45 | limit_req zone=req_limit_per_ip burst=10 nodelay;
46 | }
47 |
48 | # if the request body size is more than the buffer size, then the entire (or partial)
49 | # request body is written into a temporary file
50 | client_body_buffer_size 128k;
51 |
52 | # headerbuffer size for the request header from client -- for testing environment
53 | client_header_buffer_size 3m;
54 |
55 | # maximum number and size of buffers for large headers to read from client request
56 | large_client_header_buffers 4 256k;
57 |
58 | # read timeout for the request body from client -- for testing environment
59 | client_body_timeout 3m;
60 |
61 | # how long to wait for the client to send a request header -- for testing environment
62 | client_header_timeout 3m;
63 |
64 | # copies data between one FD and other from within the kernel
65 | # faster then read() + write()
66 | sendfile on;
67 |
68 | # send headers in one peace, its better then sending them one by one
69 | tcp_nopush on;
70 |
71 | # don't buffer data sent, good for small data bursts in real time
72 | tcp_nodelay on;
73 |
74 | # allow the server to close connection on non responding client, this will free up memory
75 | reset_timedout_connection on;
76 |
77 | # request timed out -- default 60
78 | client_body_timeout 10;
79 |
80 | # if client stop responding, free up memory -- default 60
81 | send_timeout 2;
82 |
83 | # server will close connection after this time -- default 75
84 | keepalive_timeout 30;
85 |
86 | location ~ ^/index\.php$ {
87 | fastcgi_split_path_info ^(.+\.php)(/.+)$;
88 | fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
89 | fastcgi_index index.php;
90 | include fastcgi_params;
91 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
92 | fastcgi_intercept_errors off;
93 | fastcgi_buffer_size 16k;
94 | fastcgi_buffers 4 16k;
95 | fastcgi_connect_timeout 300;
96 | fastcgi_send_timeout 300;
97 | fastcgi_read_timeout 300;
98 | try_files $uri $uri/ =404;
99 | }
100 |
101 | location ~ \.php$ {
102 | return 404;
103 | }
104 |
105 | location ~ \.sh {
106 | return 404;
107 | }
108 |
109 | location ~ /\.ht {
110 | deny all;
111 | }
112 |
113 | location ~ /.well-known {
114 | allow all;
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_domain_nonssl.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Created by afiniel for crypto use...
5 | #####################################################
6 | source /etc/functions.sh
7 | source /etc/yiimpool.conf
8 | source $STORAGE_ROOT/yiimp/.yiimp.conf
9 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
10 |
11 | set -eu -o pipefail
12 |
13 | function print_error {
14 | read line file <<<$(caller)
15 | echo "An error occurred in line $line of file $file:" >&2
16 | sed "${line}q;d" "$file" >&2
17 | }
18 | trap print_error ERR
19 |
20 | if [[ ("$wireguard" == "true") ]]; then
21 | source $STORAGE_ROOT/yiimp/.wireguard.conf
22 | fi
23 |
24 | echo '#####################################################
25 | # Source Generated by nginxconfig.io
26 | # Updated by afiniel for crypto use...
27 | #####################################################
28 | # NGINX Simple DDoS Defense
29 | limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
30 | limit_conn conn_limit_per_ip 80;
31 | limit_req zone=req_limit_per_ip burst=80 nodelay;
32 | limit_req_zone $binary_remote_addr zone=req_limit_per_ip:40m rate=5r/s;
33 | server {
34 | listen 443 ssl http2;
35 | listen [::]:443 ssl http2;
36 | server_name www.'"${DomainName}"';
37 | set $base "/var/www/'"${DomainName}"'/html";
38 | root $base/web;
39 | # SSL
40 | ssl_certificate '"${STORAGE_ROOT}"'/ssl/ssl_certificate.pem;
41 | ssl_certificate_key '"${STORAGE_ROOT}"'/ssl/ssl_private_key.pem;
42 | # security
43 | include yiimpool/security.conf;
44 | # logging
45 | access_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.access.log;
46 | error_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.error.log warn;
47 | # index.php
48 | index index.php;
49 | # index.php fallback
50 | location / {
51 | try_files $uri $uri/ /index.php?$args;
52 | }
53 | location @rewrite {
54 | rewrite ^/(.*)$ /index.php?r=$1;
55 | }
56 | # handle .php
57 | location ~ \.php$ {
58 | include yiimpool/php_fastcgi.conf;
59 | }
60 | # additional config
61 | include yiimpool/general.conf;
62 | }
63 | # HTTP redirect
64 | server {
65 | listen 80;
66 | listen [::]:80;
67 | server_name .'"${DomainName}"';
68 | include yiimpool/letsencrypt.conf;
69 | location / {
70 | return 301 https://'"${DomainName}"'$request_uri;
71 | }
72 | }
73 | ' | sudo -E tee /etc/nginx/sites-available/${DomainName}.conf >/dev/null 2>&1
74 |
75 | sudo ln -s /etc/nginx/sites-available/${DomainName}.conf /etc/nginx/sites-enabled/${DomainName}.conf
76 | sudo ln -s $STORAGE_ROOT/yiimp/site/web /var/www/${DomainName}/html
77 |
78 | restart_service nginx
79 | restart_service php7.3-fpm
80 | set +eu +o pipefail
81 | cd $HOME/yiimp_install_script/yiimp_single
82 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_domain_nossl.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Created by Afiniel for Yiimpool use...
5 | #####################################################
6 | source /etc/functions.sh
7 | source /etc/yiimpool.conf
8 | source $STORAGE_ROOT/yiimp/.yiimp.conf
9 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
10 |
11 | set -eu -o pipefail
12 |
13 | function print_error {
14 | read line file <<<$(caller)
15 | echo "An error occurred in line $line of file $file:" >&2
16 | sed "${line}q;d" "$file" >&2
17 | }
18 | trap print_error ERR
19 |
20 | if [[ ("$wireguard" == "true") ]]; then
21 | source $STORAGE_ROOT/yiimp/.wireguard.conf
22 | fi
23 |
24 | echo '#####################################################
25 | # Source Generated by nginxconfig.io
26 | # Updated by afiniel for crypto use...
27 | #####################################################
28 | # NGINX Simple DDoS Defense
29 | limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
30 | limit_conn conn_limit_per_ip 80;
31 | limit_req zone=req_limit_per_ip burst=80 nodelay;
32 | limit_req_zone $binary_remote_addr zone=req_limit_per_ip:40m rate=5r/s;
33 | server {
34 | listen 443 ssl http2;
35 | listen [::]:443 ssl http2;
36 | server_name '"${DomainName}"';
37 | set $base "/var/www/'"${DomainName}"'/html";
38 | root $base/web;
39 | # SSL
40 | ssl_certificate '"${STORAGE_ROOT}"'/ssl/ssl_certificate.pem;
41 | ssl_certificate_key '"${STORAGE_ROOT}"'/ssl/ssl_private_key.pem;
42 | # security
43 | include afiniel/security.conf;
44 | # logging
45 | access_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.access.log;
46 | error_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.error.log warn;
47 | # index.php
48 | index index.php;
49 | # index.php fallback
50 | location / {
51 | try_files $uri $uri/ /index.php?$args;
52 | }
53 | location @rewrite {
54 | rewrite ^/(.*)$ /index.php?r=$1;
55 | }
56 | # handle .php
57 | location ~ \.php$ {
58 | include afiniel/php_fastcgi.conf;
59 | }
60 | # additional config
61 | include afiniel/general.conf;
62 | }
63 | # HTTP redirect
64 | server {
65 | listen 80;
66 | listen [::]:80;
67 | server_name .'"${DomainName}"';
68 | include afiniel/letsencrypt.conf;
69 | location / {
70 | return 301 https://'"${DomainName}"'$request_uri;
71 | }
72 | }
73 | ' | sudo -E tee /etc/nginx/sites-available/${DomainName}.conf >/dev/null 2>&1
74 |
75 | sudo ln -s /etc/nginx/sites-available/${DomainName}.conf /etc/nginx/sites-enabled/${DomainName}.conf
76 | sudo ln -s $STORAGE_ROOT/yiimp/site/web /var/www/${DomainName}/html
77 |
78 | restart_service nginx
79 | restart_service php7.3-fpm
80 | set +eu +o pipefail
81 | cd $HOME/yiimp_install_script/yiimp_single
82 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_domain_ssl.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Created by Afiniel for Yiimpool use...
5 | #####################################################
6 | source /etc/functions.sh
7 | source /etc/yiimpool.conf
8 | source $STORAGE_ROOT/yiimp/.yiimp.conf
9 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
10 |
11 | set -eu -o pipefail
12 |
13 | function print_error {
14 | read line file <<<$(caller)
15 | echo "An error occurred in line $line of file $file:" >&2
16 | sed "${line}q;d" "$file" >&2
17 | }
18 | trap print_error ERR
19 |
20 | if [[ ("$wireguard" == "true") ]]; then
21 | source $STORAGE_ROOT/yiimp/.wireguard.conf
22 | fi
23 |
24 | echo -e "$YELLOW => Generating Certbot Request for$GREEN ${DomainName} <= $COL_RESET"
25 | sudo mkdir -p /var/www/_letsencrypt
26 | sudo chown www-data /var/www/_letsencrypt
27 | hide_output sudo certbot certonly --webroot -d "${DomainName}" --register-unsafely-without-email -w /var/www/_letsencrypt -n --agree-tos --force-renewal
28 | # Check to make sure certbot installed ok, if not keep the self generated ssl config.
29 | if sudo [ -f /etc/letsencrypt/live/"$DomainName"/fullchain.pem ]; then
30 | # Configure Certbot to reload NGINX after success renew:
31 | sudo mkdir -p /etc/letsencrypt/renewal-hooks/post/
32 | echo '#!/bin/bash\nnginx -t && systemctl reload nginx' | sudo -E tee /etc/letsencrypt/renewal-hooks/post/nginx-reload.sh >/dev/null 2>&1
33 | sudo chmod a+x /etc/letsencrypt/renewal-hooks/post/nginx-reload.sh
34 | # Remove the '"${DomainName}"'.conf that had the self signed SSL and replace with the new file.
35 | sudo rm /etc/nginx/sites-available/${DomainName}.conf
36 | # I am SSL Man!
37 | echo '#####################################################
38 | # Source Generated by nginxconfig.io
39 | # Updated by afiniel for crypto use...
40 | #####################################################
41 | # NGINX Simple DDoS Defense
42 | limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
43 | limit_conn conn_limit_per_ip 80;
44 | limit_req zone=req_limit_per_ip burst=80 nodelay;
45 | limit_req_zone $binary_remote_addr zone=req_limit_per_ip:40m rate=5r/s;
46 | server {
47 | listen 443 ssl http2;
48 | listen [::]:443 ssl http2;
49 | server_name '"${DomainName}"';
50 | set $base "/var/www/'"${DomainName}"'/html";
51 | root $base/web;
52 | # SSL
53 | ssl_certificate /etc/letsencrypt/live/'"${DomainName}"'/fullchain.pem;
54 | ssl_certificate_key /etc/letsencrypt/live/'"${DomainName}"'/privkey.pem;
55 | ssl_trusted_certificate /etc/letsencrypt/live/'"${DomainName}"'/chain.pem;
56 | # security
57 | include yiimpool/security.conf;
58 | # logging
59 | access_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.access.log;
60 | error_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.error.log warn;
61 | # index.php
62 | index index.php;
63 | # index.php fallback
64 | location / {
65 | try_files $uri $uri/ /index.php?$args;
66 | }
67 | location @rewrite {
68 | rewrite ^/(.*)$ /index.php?r=$1;
69 | }
70 | # handle .php
71 | location ~ \.php$ {
72 | include yiimpool/php_fastcgi.conf;
73 | }
74 | # additional config
75 | include yiimpool/general.conf;
76 | }
77 | # HTTP redirect
78 | server {
79 | listen 80;
80 | listen [::]:80;
81 | server_name .'"${DomainName}"';
82 | include yiimpool/letsencrypt.conf;
83 | location / {
84 | return 301 https://'"${DomainName}"'$request_uri;
85 | }
86 | }
87 | ' | sudo -E tee /etc/nginx/sites-available/${DomainName}.conf >/dev/null 2>&1
88 |
89 | restart_service nginx >/dev/null 2>&1
90 | restart_service php7.3-fpm >/dev/null 2>&1
91 | else
92 | echo -e "$GREEN Certbot$RED generation failed, after the installer is finished check$MAGENTA /var/log/letsencrypt$YELLOW (must be root to view) on why it failed. $COL_RESET"
93 | fi
94 | set +eu +o pipefail
95 |
96 | cd $HOME/yiimp_install_script/yiimp_single
97 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_subdomain_nonssl.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Created by Afiniel for Yiimpool use...
5 | #####################################################
6 | source /etc/functions.sh
7 | source /etc/yiimpool.conf
8 | source $STORAGE_ROOT/yiimp/.yiimp.conf
9 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
10 |
11 | set -eu -o pipefail
12 |
13 | function print_error {
14 | read line file <<<$(caller)
15 | echo "An error occurred in line $line of file $file:" >&2
16 | sed "${line}q;d" "$file" >&2
17 | }
18 | trap print_error ERR
19 |
20 | if [[ ("$wireguard" == "true") ]]; then
21 | source $STORAGE_ROOT/yiimp/.wireguard.conf
22 | fi
23 |
24 | echo '#####################################################
25 | # Source Generated by nginxconfig.io
26 | # Updated by afiniel for crypto use...
27 | #####################################################
28 | # NGINX Simple DDoS Defense
29 | limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
30 | limit_conn conn_limit_per_ip 80;
31 | limit_req zone=req_limit_per_ip burst=80 nodelay;
32 | limit_req_zone $binary_remote_addr zone=req_limit_per_ip:40m rate=5r/s;
33 | server {
34 | listen 443 ssl http2;
35 | listen [::]:443 ssl http2;
36 | server_name '"${DomainName}"';
37 | set $base "/var/www/'"${DomainName}"'/html";
38 | root $base/web;
39 | # SSL
40 | ssl_certificate '"${STORAGE_ROOT}"'/ssl/ssl_certificate.pem;
41 | ssl_certificate_key '"${STORAGE_ROOT}"'/ssl/ssl_private_key.pem;
42 | # security
43 | include yiimpool/security.conf;
44 | # logging
45 | access_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.access.log;
46 | error_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.error.log warn;
47 | # index.php
48 | index index.php;
49 | # index.php fallback
50 | location / {
51 | try_files $uri $uri/ /index.php?$args;
52 | }
53 | location @rewrite {
54 | rewrite ^/(.*)$ /index.php?r=$1;
55 | }
56 | # handle .php
57 | location ~ \.php$ {
58 | include yiimpool/php_fastcgi.conf;
59 | }
60 | # additional config
61 | include yiimpool/general.conf;
62 | }
63 | # HTTP redirect
64 | server {
65 | listen 80;
66 | listen [::]:80;
67 | server_name .'"${DomainName}"';
68 | include yiimpool/letsencrypt.conf;
69 | location / {
70 | return 301 https://'"${DomainName}"'$request_uri;
71 | }
72 | }
73 | ' | sudo -E tee /etc/nginx/sites-available/${DomainName}.conf >/dev/null 2>&1
74 |
75 | sudo ln -s /etc/nginx/sites-available/${DomainName}.conf /etc/nginx/sites-enabled/${DomainName}.conf
76 | sudo ln -s $STORAGE_ROOT/yiimp/site/web /var/www/${DomainName}/html
77 |
78 | restart_service nginx
79 | restart_service php7.3-fpm
80 | set +eu +o pipefail
81 | cd $HOME/yiimp_install_script/yiimp_single
82 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_subdomain_ssl.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Created by Afiniel for Yiimpool use...
5 | #####################################################
6 | source /etc/functions.sh
7 | source /etc/yiimpool.conf
8 | source $STORAGE_ROOT/yiimp/.yiimp.conf
9 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
10 |
11 | set -eu -o pipefail
12 |
13 | function print_error {
14 | read line file <<<$(caller)
15 | echo "An error occurred in line $line of file $file:" >&2
16 | sed "${line}q;d" "$file" >&2
17 | }
18 | trap print_error ERR
19 |
20 | if [[ ("$wireguard" == "true") ]]; then
21 | source $STORAGE_ROOT/yiimp/.wireguard.conf
22 | fi
23 |
24 | echo -e "$CYAN => Generating Certbot Request for$GREEN ${DomainName} $COL_RESET"
25 | sudo mkdir -p /var/www/_letsencrypt
26 | sudo chown www-data /var/www/_letsencrypt
27 | hide_output sudo certbot certonly --webroot -d "${DomainName}" --register-unsafely-without-email -w /var/www/_letsencrypt -n --agree-tos --force-renewal
28 | # Check to make sure certbot installed ok, if not keep the self generated ssl config.
29 | if sudo [ -f /etc/letsencrypt/live/"$DomainName"/fullchain.pem ]; then
30 | # Configure Certbot to reload NGINX after success renew:
31 | sudo mkdir -p /etc/letsencrypt/renewal-hooks/post/
32 | echo '#!/bin/bash\nnginx -t && systemctl reload nginx' | sudo -E tee /etc/letsencrypt/renewal-hooks/post/nginx-reload.sh >/dev/null 2>&1
33 | sudo chmod a+x /etc/letsencrypt/renewal-hooks/post/nginx-reload.sh
34 | # Remove the '"${DomainName}"'.conf that had the self signed SSL and replace with the new file.
35 | sudo rm /etc/nginx/sites-available/${DomainName}.conf
36 | # I am SSL Man!
37 | echo '#####################################################
38 | # Source Generated by nginxconfig.io
39 | # Updated by afiniel for crypto use...
40 | #####################################################
41 | # NGINX Simple DDoS Defense
42 | limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
43 | limit_conn conn_limit_per_ip 80;
44 | limit_req zone=req_limit_per_ip burst=80 nodelay;
45 | limit_req_zone $binary_remote_addr zone=req_limit_per_ip:40m rate=5r/s;
46 | server {
47 | listen 443 ssl http2;
48 | listen [::]:443 ssl http2;
49 | server_name '"${DomainName}"';
50 | set $base "/var/www/'"${DomainName}"'/html";
51 | root $base/web;
52 | # SSL
53 | ssl_certificate /etc/letsencrypt/live/'"${DomainName}"'/fullchain.pem;
54 | ssl_certificate_key /etc/letsencrypt/live/'"${DomainName}"'/privkey.pem;
55 | ssl_trusted_certificate /etc/letsencrypt/live/'"${DomainName}"'/chain.pem;
56 | # security
57 | include yiimpool/security.conf;
58 | # logging
59 | access_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.access.log;
60 | error_log '"${STORAGE_ROOT}"'/yiimp/site/log/'"${DomainName}"'.app.error.log warn;
61 | # index.php
62 | index index.php;
63 | # index.php fallback
64 | location / {
65 | try_files $uri $uri/ /index.php?$args;
66 | }
67 | location @rewrite {
68 | rewrite ^/(.*)$ /index.php?r=$1;
69 | }
70 | # handle .php
71 | location ~ \.php$ {
72 | include yiimpool/php_fastcgi.conf;
73 | }
74 | # additional config
75 | include yiimpool/general.conf;
76 | }
77 | # HTTP redirect
78 | server {
79 | listen 80;
80 | listen [::]:80;
81 | server_name .'"${DomainName}"';
82 | include yiimpool/letsencrypt.conf;
83 | location / {
84 | return 301 https://'"${DomainName}"'$request_uri;
85 | }
86 | }
87 | ' | sudo -E tee /etc/nginx/sites-available/${DomainName}.conf >/dev/null 2>&1
88 |
89 | restart_service nginx >/dev/null 2>&1
90 | restart_service php7.3-fpm >/dev/null 2>&1
91 | else
92 | echo -e "Certbot generation failed, after the installer is finished check /var/log/letsencrypt (must be root to view) on why it failed."
93 | fi
94 | set +eu +o pipefail
95 | cd $HOME/yiimp_install_script/yiimp_single
96 |
--------------------------------------------------------------------------------
/yiimp_single/nginx_upgrade.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Created by afiniel for crypto use...
5 | #####################################################
6 |
7 | source /etc/functions.sh
8 | source /etc/yiimpool.conf
9 | source $STORAGE_ROOT/yiimp/.yiimp.conf
10 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
11 | cd $HOME/yiimp_install_script/yiimp_single
12 |
13 | set -eu -o pipefail
14 |
15 | function print_error {
16 | read line file <<<$(caller)
17 | echo "An error occurred in line $line of file $file:" >&2
18 | sed "${line}q;d" "$file" >&2
19 | }
20 | trap print_error ERR
21 | term_art
22 | echo -e "$MAGENTA <----------------------------------> $COL_RESET"
23 | echo -e "$MAGENTA Database$YELLOW build and tweak$GREEN completed $COL_RESET"
24 | echo -e "$MAGENTA <----------------------------------> $COL_RESET"
25 | echo -e "$GREEN Passwords can be found in$RED $STORAGE_ROOT/yiimp/.my.cnf $COL_RESET $COL_RESET"
26 |
27 | if [[ ("$wireguard" == "true") ]]; then
28 | source $STORAGE_ROOT/yiimp/.wireguard.conf
29 | fi
30 |
31 | # NGINX upgrade TODO: CLEAN UP
32 | echo -e "$YELLOW => Upgrading NGINX <= $COL_RESET"
33 |
34 | # Grab Nginx key and proper mainline package for distro
35 | echo "deb http://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" \
36 | | sudo tee /etc/apt/sources.list.d/nginx.list >/dev/null 2>&1
37 |
38 | sudo curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add - >/dev/null 2>&1
39 | hide_output sudo apt-get update
40 | hide_output sudo apt-get install -y nginx
41 |
42 | # Make additional conf directories, move and generate needed configurations.
43 | sudo mkdir -p /etc/nginx/yiimpool
44 | #sudo mkdir -p /etc/nginx/sites-available
45 | #sudo mkdir -p /etc/nginx/sites-enabled
46 |
47 | sudo mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old
48 | sudo cp -r nginx_confs/nginx.conf /etc/nginx/
49 | sudo cp -r nginx_confs/general.conf /etc/nginx/yiimpool
50 | sudo cp -r nginx_confs/php_fastcgi.conf /etc/nginx/yiimpool
51 | sudo cp -r nginx_confs/security.conf /etc/nginx/yiimpool
52 | sudo cp -r nginx_confs/letsencrypt.conf /etc/nginx/yiimpool
53 |
54 | # Removing default nginx site configs.
55 | #sudo rm -r /etc/nginx/conf.d/default.conf
56 | sudo rm -r /etc/nginx/sites-enabled/default
57 | sudo rm -r /etc/nginx/sites-available/default*
58 |
59 | echo -e "$GREEN NGINX upgrade complete.$COL_RESET"
60 | restart_service nginx
61 | restart_service php7.3-fpm
62 |
63 | set +eu +o pipefail
64 |
65 | cd $HOME/yiimp_install_script/yiimp_single
66 |
--------------------------------------------------------------------------------
/yiimp_single/self_ssl.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox
5 | # Updated by afiniel for crypto use...
6 | #####################################################
7 |
8 | # Load required functions and configurations
9 | source /etc/functions.sh
10 | source /etc/yiimpool.conf
11 | source $STORAGE_ROOT/yiimp/.yiimp.conf
12 |
13 | # Exit on error and enable pipe fail
14 | set -euo pipefail
15 |
16 | # Function to print error messages
17 | print_error() {
18 | local line file
19 | read -r line file <<< "$(caller)"
20 | echo "Error in line $line of file $file:" >&2
21 | sed "${line}q;d" "$file" >&2
22 | }
23 |
24 | trap print_error ERR
25 |
26 | term_art
27 | echo -e "$MAGENTA <-------------------------------------->$COL_RESET"
28 | echo -e "$MAGENTA <--$YELLOW Creating initial SSL certificate$MAGENTA -->$COL_RESET"
29 | echo -e "$MAGENTA <-------------------------------------->$COL_RESET"
30 |
31 | # Install OpenSSL
32 | apt_install openssl
33 |
34 | # Create SSL directory
35 | sudo mkdir -p "$STORAGE_ROOT/ssl"
36 |
37 | # Generate private key
38 | if [ ! -f "$STORAGE_ROOT/ssl/ssl_private_key.pem" ]; then
39 | (
40 | umask 077
41 | hide_output sudo openssl genrsa -out "$STORAGE_ROOT/ssl/ssl_private_key.pem" 2048
42 | )
43 | fi
44 |
45 | # Generate self-signed certificate
46 | if [ ! -f "$STORAGE_ROOT/ssl/ssl_certificate.pem" ]; then
47 | CSR="/tmp/ssl_cert_sign_req-$RANDOM.csr"
48 | hide_output sudo openssl req -new -key "$STORAGE_ROOT/ssl/ssl_private_key.pem" -out "$CSR" \
49 | -sha256 -subj "/CN=$PRIMARY_HOSTNAME"
50 |
51 | CERT="$STORAGE_ROOT/ssl/$PRIMARY_HOSTNAME-selfsigned-$(date --rfc-3339=date | tr -d '-').pem"
52 | hide_output sudo openssl x509 -req -days 365 -in "$CSR" -signkey "$STORAGE_ROOT/ssl/ssl_private_key.pem" -out "$CERT"
53 |
54 | sudo rm -f "$CSR"
55 | sudo ln -s "$CERT" "$STORAGE_ROOT/ssl/ssl_certificate.pem"
56 | fi
57 |
58 | # Generate Diffie-Hellman cipher bits
59 | if [ ! -f /etc/nginx/dhparam.pem ]; then
60 | hide_output sudo openssl dhparam -out /etc/nginx/dhparam.pem 2048
61 | fi
62 |
63 | echo -e "$GREEN => Initial self-signed SSL generation complete <= $COL_RESET"
64 | cd "$HOME/yiimp_install_script/yiimp_single"
65 |
--------------------------------------------------------------------------------
/yiimp_single/send_mail.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Created by Afiniel for Yiimpool use...
5 | #####################################################
6 |
7 | source /etc/functions.sh
8 | source /etc/yiimpool.conf
9 | source $STORAGE_ROOT/yiimp/.yiimp.conf
10 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
11 |
12 | set -eu -o pipefail
13 |
14 | function print_error {
15 | read line file <<<$(caller)
16 | echo "An error occurred in line $line of file $file:" >&2
17 | sed "${line}q;d" "$file" >&2
18 | }
19 | trap print_error ERR
20 |
21 | if [[ ("$wireguard" == "true") ]]; then
22 | source $STORAGE_ROOT/yiimp/.wireguard.conf
23 | fi
24 |
25 | echo -e "$YELLOW => Installing mail system <= $COL_RESET"
26 |
27 | apt_install postfix
28 | apt_install mailutils
29 |
30 | sudo debconf-set-selections <<<"postfix postfix/mailname string ${PRIMARY_HOSTNAME}"
31 | sudo debconf-set-selections <<<"postfix postfix/main_mailer_type string 'Internet Site'"
32 | # sudo apt-get install mailutils -y
33 |
34 | sudo sed -i 's/inet_interfaces = all/inet_interfaces = loopback-only/g' /etc/postfix/main.cf
35 | sudo sed -i 's/myhostname =/# myhostname =/g' /etc/postfix/main.cf
36 | sudo sed -i 's/mydestination/# mydestination/g' /etc/postfix/main.cf
37 | sudo sed -i '/# mydestination/i mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain' /etc/postfix/main.cf
38 | sudo sed -i '/# myhostname =/i myhostname = localhost' /etc/postfix/main.cf
39 |
40 | sudo systemctl restart postfix
41 | whoami=$(whoami)
42 |
43 | cd $HOME/etc/
44 | sudo touch aliases
45 | sudo sed -i '/postmaster: root/a root: '${SupportEmail}'' /etc/aliases
46 | sudo sed -i '/root:/a '$whoami': '${SupportEmail}'' /etc/aliases
47 | sudo newaliases
48 |
49 | sudo adduser $whoami mail
50 | echo -e "$GREEN Mail system complete $COL_RESET"
51 | set +eu +o pipefail
52 | cd $HOME/yiimp_install_script/yiimp_single
53 |
--------------------------------------------------------------------------------
/yiimp_single/server_harden.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Source various web sources:
5 | # https://www.linuxbabe.com/ubuntu/enable-google-tcp-bbr-ubuntu
6 | # https://www.cyberciti.biz/faq/linux-tcp-tuning/
7 | # Created by Afiniel for Yiimpool use...
8 | #####################################################
9 |
10 | source /etc/functions.sh
11 | source /etc/yiimpool.conf
12 |
13 | echo
14 | echo -e "$GREEN => Boosting server performance for YiiMP <= $COL_RESET"
15 | # Boost Network Performance by Enabling TCP BBR
16 | hide_output sudo apt install -y --install-recommends linux-generic-hwe-16.04
17 | echo 'net.core.default_qdisc=fq' | hide_output sudo tee -a /etc/sysctl.conf
18 | echo 'net.ipv4.tcp_congestion_control=bbr' | hide_output sudo tee -a /etc/sysctl.conf
19 |
20 | # Tune Network Stack
21 | echo 'net.core.wmem_max=12582912' | hide_output sudo tee -a /etc/sysctl.conf
22 | echo 'net.core.rmem_max=12582912' | hide_output sudo tee -a /etc/sysctl.conf
23 | echo 'net.ipv4.tcp_rmem= 10240 87380 12582912' | hide_output sudo tee -a /etc/sysctl.conf
24 | echo 'net.ipv4.tcp_wmem= 10240 87380 12582912' | hide_output sudo tee -a /etc/sysctl.conf
25 | echo 'net.ipv4.tcp_window_scaling = 1' | hide_output sudo tee -a /etc/sysctl.conf
26 | echo 'net.ipv4.tcp_timestamps = 1' | hide_output sudo tee -a /etc/sysctl.conf
27 | echo 'net.ipv4.tcp_sack = 1' | hide_output sudo tee -a /etc/sysctl.conf
28 | echo 'net.ipv4.tcp_no_metrics_save = 1' | hide_output sudo tee -a /etc/sysctl.conf
29 | echo 'net.core.netdev_max_backlog = 5000' | hide_output sudo tee -a /etc/sysctl.conf
30 |
31 | cd $HOME/yiimp_install_script/yiimp_single
32 |
--------------------------------------------------------------------------------
/yiimp_single/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | ##################################################################################
4 | # This is the entry point for configuring the system. #
5 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox #
6 | # Updated by Afiniel for yiimpool use... #
7 | ##################################################################################
8 |
9 | source /etc/yiimpoolversion.conf
10 | source /etc/functions.sh
11 | source /etc/yiimpool.conf
12 |
13 | # Ensure Python reads/writes files in UTF-8. If the machine
14 | # triggers some other locale in Python, like ASCII encoding,
15 | # Python may not be able to read/write files. This is also
16 | # in the management daemon startup script and the cron script.
17 |
18 | if ! locale -a | grep en_US.utf8 > /dev/null; then
19 | # Generate locale if not exists
20 | hide_output locale-gen en_US.UTF-8
21 | fi
22 |
23 | export LANGUAGE=en_US.UTF-8
24 | export LC_ALL=en_US.UTF-8
25 | export LANG=en_US.UTF-8
26 | export LC_TYPE=en_US.UTF-8
27 |
28 | # Fix so line drawing characters are shown correctly in Putty on Windows. See #744.
29 | export NCURSES_NO_UTF8_ACS=1
30 |
31 | # Create the temporary installation directory if it doesn't already exist.
32 | if [ ! -d $STORAGE_ROOT/yiimp/yiimp_setup ]; then
33 | sudo mkdir -p $STORAGE_ROOT/{wallets,yiimp/{yiimp_setup/log,site/{web,stratum,configuration,crons,log},starts}}
34 | sudo touch $STORAGE_ROOT/yiimp/yiimp_setup/log/installer.log
35 | fi
36 | echo
37 |
38 | # Start the installation.
39 | source menu.sh
40 | source questions.sh
41 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
42 |
43 | if [[ ("$wireguard" == "true") ]]; then
44 | source wireguard.sh
45 | fi
46 |
47 | source system.sh
48 | source self_ssl.sh
49 | source db.sh
50 | source nginx_upgrade.sh
51 | source web.sh
52 | sudo bash stratum.sh
53 | source compile_crypto.sh
54 | #source daemon.sh
55 |
56 | # if [[ ("$UsingDomain" == "yes") ]]; then
57 | # source send_mail.sh
58 | # fi
59 |
60 | source server_cleanup.sh
61 | source motd.sh
62 | source server_harden.sh
63 | source $STORAGE_ROOT/yiimp/.yiimp.conf
64 |
65 | clear
66 |
67 | if [[ ("$UsingDomain" == "yes") ]]; then
68 | source /etc/yiimpool.conf
69 | source /etc/yiimpoolversion.conf
70 | source /etc/functions.sh
71 | term_yiimpool
72 | echo -e "$CYAN<-----------------------------------------------------------------------------> $COL_RESET"
73 | echo -e "$YELLOW Thank you for using Yiimp Install Script$GREEN $VERSION $YELLOW fork by Afiniel! $COL_RESET"
74 | echo
75 | echo -e "$YELLOW => To run this installer anytime simply type:$GREEN yiimpool $COL_RESET"
76 | echo -e "$CYAN<-----------------------------------------------------------------------------> $COL_RESET"
77 | echo -e "$YELLOW => Do you like the installer and want to support the project? use wallets below: $COL_RESET"
78 | echo -e "$CYAN<-----------------------------------------------------------------------------> $COL_RESET"
79 | echo -e "$YELLOW => BTC:$GREEN $BTCDON $COL_RESET"
80 | echo
81 | echo -e "$YELLOW => BCH:$GREEN $BCHDON $COL_RESET"
82 | echo
83 | echo -e "$YELLOW => ETH:$GREEN $ETHDON $COL_RESET"
84 | echo
85 | echo -e "$YELLOW => DOGE:$GREEN $DOGEDON $COL_RESET"
86 | echo
87 | echo -e "$YELLOW => LTC:$GREEN $LTCDON $COL_RESET"
88 | echo -e "$CYAN<-----------------------------------------------------------------------------> $COL_RESET"
89 | echo
90 | echo -e "$YELLOW Installation of your Yiimp is now$GREEN completed. $COL_RESET"
91 | echo -e "$YELLOW You $RED*MUST REBOOT*$YELLOW the machine to finalize the machine updates and folder permissions! $MAGENTA YiiMP will not function until a$RED reboot$YELLOW is performed!$COL_RESET"
92 | echo
93 | echo -e "$YELLOW Important! After first$RED reboot$YELLOW it may take up to 1 minute for the$GREEN main$YELLOW|$GREEN loop2$YELLOW|$GREEN blocks$YELLOW|$GREEN debug$YELLOW screens to start!$COL_RESET"
94 | echo -e "$YELLOW If they show$RED stopped,$YELLOW after 1 minute, type$GREEN motd$YELLOW to$GREEN refresh$YELLOW the screen.$COL_RESET"
95 | echo
96 | echo -e "$YELLOW You can access your$GREEN ${AdminPanel} $YELLOW at,$BLUE http://${DomainName}/site/${AdminPanel} $COL_RESET"
97 | echo
98 | echo -e "$RED By default all stratum ports are blocked by the firewall.$YELLOW To allow a port through, from the command prompt type $GREEN sudo ufw allow port number.$COL_RESET"
99 | echo -e "$GREEN Database user names and passwords$YELLOW can be found in$RED $STORAGE_ROOT/yiimp/.my.cnf$COL_RESET"
100 | exit 0
101 | else
102 | source /etc/yiimpool.conf
103 | source /etc/functions.sh
104 | term_yiimpool
105 | echo -e "$CYAN<-----------------------------------------------------------------------------> $COL_RESET"
106 | echo -e "$YELLOW Thank you for using Yiimp Install Script$GREEN $VERSION $YELLOW fork by Afiniel! $COL_RESET"
107 | echo
108 | echo -e "$YELLOW => To run this installer anytime simply type:$GREEN yiimpool $COL_RESET"
109 | echo -e "$CYAN<-----------------------------------------------------------------------------> $COL_RESET"
110 | echo -e "$YELLOW => Do you like the installer and want to support the project? use wallets below: $COL_RESET"
111 | echo -e "$CYAN<-----------------------------------------------------------------------------> $COL_RESET"
112 | echo -e "$CYAN => BTC:$GREEN $BTCDON $COL_RESET"
113 | echo
114 | echo -e "$CYAN => BCH:$GREEN $BCHDON $COL_RESET"
115 | echo
116 | echo -e "$CYAN => ETH:$GREEN $ETHDON $COL_RESET"
117 | echo
118 | echo -e "$CYAN => DOGE:$GREEN $DOGEDON $COL_RESET"
119 | echo
120 | echo -e "$CYAN => LTC:$GREEN $LTCDON $COL_RESET"
121 | echo -e "$CYAN<-----------------------------------------------------------------------------> $COL_RESET"
122 | echo
123 | echo -e "$YELLOW Installation of your Yiimp is now$GREEN completed."
124 | echo -e "$YELLOW You $RED*MUST REBOOT*$YELLOW the machine to finalize the machine updates and folder permissions! $MAGENTA YiiMP will not function until a$RED reboot$YELLOW is performed!$COL_RESET"
125 | echo
126 | echo -e "$YELLOW Important! After first$RED reboot$YELLOW it may take up to 1 minute for the$GREEN main$YELLOW|$GREEN loop2$YELLOW|$GREEN blocks$YELLOW|$GREEN debug$YELLOW screens to start!$COL_RESET"
127 | echo -e "$YELLOW If they show$RED stopped,$YELLOW after 1 minute, type$GREEN motd$YELLOW to$GREEN refresh$YELLOW the screen.$COL_RESET"
128 | echo
129 | echo -e "$YELLOW You can access your$GREEN $AdminPanel $YELLOW at,$BLUE http://${DomainName}/site/${AdminPanel} $COL_RESET"
130 | echo
131 | echo -e "$RED By default all stratum ports are blocked by the firewall.$YELLOW To allow a port through, from the command prompt type $GREEN sudo ufw allow port number.$COL_RESET"
132 | echo -e "$GREEN Database user names and passwords$YELLOW can be found in$RED $STORAGE_ROOT/yiimp/.my.cnf$COL_RESET"
133 | fi
134 |
--------------------------------------------------------------------------------
/yiimp_single/stratum.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##########################################
4 | # Created by Afiniel for Yiimpool use... #
5 | ##########################################
6 |
7 | source /etc/functions.sh
8 | source /etc/yiimpool.conf
9 | source $STORAGE_ROOT/yiimp/.yiimp.conf
10 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
11 |
12 | echo
13 | term_art
14 | echo -e "$MAGENTA <--------------------->$COL_RESET"
15 | echo -e "$MAGENTA <--$YELLOW Compile Stratum$MAGENTA -->$COL_RESET"
16 | echo -e "$MAGENTA <--------------------->$COL_RESET"
17 | cd /home/crypto-data/yiimp/yiimp_setup
18 |
19 | # Starting the build progress of the stratum
20 | echo
21 | echo -e "$MAGENTA => Building$GREEN blocknotify$MAGENTA ,$GREEN iniparser$MAGENTA ,$GREEN stratum$MAGENTA ... <= $COL_RESET"
22 |
23 | # Generating Random Password for stratum
24 | blckntifypass=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`
25 |
26 | # Compil Blocknotify
27 | cd /home/crypto-data/yiimp/yiimp_setup/yiimp/blocknotify
28 | sudo sed -i 's/tu8tu5/'$blckntifypass'/' blocknotify.cpp
29 | hide_output make -j$((`nproc`+1))
30 |
31 | # Compil Stratum
32 | cd /home/crypto-data/yiimp/yiimp_setup/yiimp/stratum
33 | hide_output git submodule init && hide_output git submodule update
34 | hide_output sudo make -C algos
35 | hide_output sudo make -C sha3
36 | hide_output sudo make -C iniparser
37 | cd secp256k1 && chmod +x autogen.sh && hide_output ./autogen.sh && hide_output ./configure --enable-experimental --enable-module-ecdh --with-bignum=no --enable-endomorphism && hide_output make -j$((`nproc`+1))
38 | if [[ ("$AutoExchange" == "y" || "$AutoExchange" == "Y" || "$AutoExchange" == "yes") ]]; then
39 | sudo sed -i 's/CFLAGS += -DNO_EXCHANGE/#CFLAGS += -DNO_EXCHANGE/' $HOME/yiimp/stratum/Makefile
40 | fi
41 | cd /home/crypto-data/yiimp/yiimp_setup/yiimp/stratum
42 | hide_output make -j$((`nproc`+1))
43 |
44 | echo -e "$CYAN => Building stratum folder structure and copying files... <= $COL_RESET"
45 | cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/stratum
46 | sudo cp -a config.sample/. $STORAGE_ROOT/yiimp/site/stratum/config
47 | sudo cp -r stratum $STORAGE_ROOT/yiimp/site/stratum
48 | sudo cp -r run.sh $STORAGE_ROOT/yiimp/site/stratum
49 | cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp
50 | sudo cp -r $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/blocknotify/blocknotify $STORAGE_ROOT/yiimp/site/stratum
51 | sudo cp -r $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/blocknotify/blocknotify /usr/bin
52 |
53 | sudo rm -r $STORAGE_ROOT/yiimp/site/stratum/config/run.sh
54 | echo '#!/usr/bin/env bash
55 | source /etc/yiimpool.conf
56 | source $STORAGE_ROOT/yiimp/.yiimp.conf
57 | ulimit -n 10240
58 | ulimit -u 10240
59 | cd '""''"${STORAGE_ROOT}"''""'/yiimp/site/stratum
60 | while true; do
61 | ./stratum config/$1
62 | sleep 2
63 | done
64 | exec bash' | sudo -E tee $STORAGE_ROOT/yiimp/site/stratum/config/run.sh >/dev/null 2>&1
65 | sudo chmod +x $STORAGE_ROOT/yiimp/site/stratum/config/run.sh
66 |
67 | sudo rm -r $STORAGE_ROOT/yiimp/site/stratum/run.sh
68 | echo '#!/usr/bin/env bash
69 | source /etc/yiimpool.conf
70 | source $STORAGE_ROOT/yiimp/.yiimp.conf
71 | cd '""''"${STORAGE_ROOT}"''""'/yiimp/site/stratum/config/ && ./run.sh $*
72 | ' | sudo -E tee $STORAGE_ROOT/yiimp/site/stratum/run.sh >/dev/null 2>&1
73 | sudo chmod +x $STORAGE_ROOT/yiimp/site/stratum/run.sh
74 |
75 | echo -e "$YELLOW => Updating stratum config files with database$GREEN connection$YELLOW info <= $COL_RESET"
76 | cd $STORAGE_ROOT/yiimp/site/stratum/config
77 |
78 | sudo sed -i 's/password = tu8tu5/password = '${blckntifypass}'/g' *.conf
79 | sudo sed -i 's/server = yaamp.com/server = '${StratumURL}'/g' *.conf
80 | if [[ ("$wireguard" == "true") ]]; then
81 | sudo sed -i 's/host = yaampdb/host = '${DBInternalIP}'/g' *.conf
82 | else
83 | sudo sed -i 's/host = yaampdb/host = localhost/g' *.conf
84 | fi
85 | sudo sed -i 's/database = yaamp/database = '${YiiMPDBName}'/g' *.conf
86 | sudo sed -i 's/username = root/username = '${StratumDBUser}'/g' *.conf
87 | sudo sed -i 's/password = patofpaq/password = '${StratumUserDBPassword}'/g' *.conf
88 |
89 | #set permissions
90 | sudo setfacl -m u:$USER:rwx $STORAGE_ROOT/yiimp/site/stratum/
91 | sudo setfacl -m u:$USER:rwx $STORAGE_ROOT/yiimp/site/stratum/config
92 |
93 | sleep 1.5
94 | term_art
95 | echo -e "$GREEN => Stratum build complete $COL_RESET"
96 | cd $HOME/yiimp_install_script/yiimp_single
--------------------------------------------------------------------------------
/yiimp_single/ubuntu/blocknotify.sh:
--------------------------------------------------------------------------------
1 | ##########################################
2 | # Updated by Afiniel for Yiimpool use... #
3 | ##########################################
4 | #!/bin/bash
5 | blocknotify stratum_one:$1 $2 $3
6 | blocknotify stratum_two:$1 $2 $3
7 | blocknotify stratum_three:$1 $2 $3
8 |
--------------------------------------------------------------------------------
/yiimp_single/ubuntu/etc/update-motd.d/00-header:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # 00-header - create the header of the MOTD
4 | # Copyright (c) 2013 Nick Charlton
5 | # Copyright (c) 2009-2010 Canonical Ltd.
6 | #
7 | # Authors: Nick Charlton
8 | # Dustin Kirkland
9 | #
10 | # This program is free software; you can redistribute it and/or modify
11 | # it under the terms of the GNU General Public License as published by
12 | # the Free Software Foundation; either version 2 of the License, or
13 | # (at your option) any later version.
14 | #
15 | # This program is distributed in the hope that it will be useful,
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | # GNU General Public License for more details.
19 | #
20 | # You should have received a copy of the GNU General Public License along
21 | # with this program; if not, write to the Free Software Foundation, Inc.,
22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 | #-------------------------------------------------------------------------------
24 | # Updated by Afiniel for Yiimpool use...
25 | #-------------------------------------------------------------------------------
26 |
27 | clear
28 |
29 | [ -r /etc/lsb-release ] && . /etc/lsb-release
30 |
31 | if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
32 | # Fall back to using the very slow lsb_release utility
33 | DISTRIB_DESCRIPTION=$(lsb_release -s -d)
34 | fi
35 |
36 | figlet -f slant -w 100 "YiimpooL" | lolcat -f
37 | printf "\n"
38 |
39 | printf "Welcome to %s (%s).\n" "$DISTRIB_DESCRIPTION" "YiimPool Version"
40 | printf "\n"
41 |
--------------------------------------------------------------------------------
/yiimp_single/ubuntu/etc/update-motd.d/10-sysinfo:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # 10-sysinfo - generate the system information
4 | # Copyright (c) 2013 Nick Charlton
5 | #
6 | # Authors: Nick Charlton
7 | #
8 | # This program is free software; you can redistribute it and/or modify
9 | # it under the terms of the GNU General Public License as published by
10 | # the Free Software Foundation; either version 2 of the License, or
11 | # (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful,
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | # GNU General Public License for more details.
17 | #
18 | # You should have received a copy of the GNU General Public License along
19 | # with this program; if not, write to the Free Software Foundation, Inc.,
20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 | #
22 | ##########################################
23 | # #
24 | # Updated by Afiniel for Yiimpool use... #
25 | # #
26 | ##########################################
27 |
28 | source /etc/yiimpooldonate.conf
29 | source /etc/yiimpool.conf
30 | source /etc/functions.sh
31 |
32 | # Define colors
33 | RED=$'\033[00;31m'
34 | GREEN=$'\033[00;32m'
35 | YELLOW=$'\033[00;33m'
36 | CYAN=$'\033[00;36m'
37 | RESET=$'\033[0m'
38 |
39 | # Function to check process status
40 | check_process_status() {
41 | local process_name="$1"
42 | if ps aux | grep -q "[${process_name:0:1}]${process_name:1}"; then
43 | echo "${GREEN}running${RESET}"
44 | else
45 | echo "${RED}stopped${RESET}"
46 | fi
47 | }
48 |
49 | # Function to display header information
50 | print_header() {
51 | printf "%-7s %-25s %-16s %-15s\n" "$1" "$2" "$3" "$4"
52 | }
53 |
54 | # Function to display a colored message
55 | colored_message() {
56 | echo "${CYAN}$1${RESET}"
57 | }
58 |
59 | # Display current date and time
60 | date=$(date)
61 | echo -e "${YELLOW}Current date and time:${GREEN} $date ${RESET}"
62 | echo
63 |
64 | # Display system information
65 | colored_message "System information:"
66 | echo
67 | /usr/bin/landscape-sysinfo
68 | echo
69 |
70 | # Pool status
71 | colored_message "Pool Status:"
72 | daemon='/home/crypto-data/wallets'
73 | site='/home/crypto-data/yiimp/site'
74 | echo
75 | print_header "Main:" "$(check_process_status 'main')" \
76 | "Daemon Directory:" "${YELLOW}$daemon${RESET}"
77 |
78 | print_header "Blocks:" "$(check_process_status 'blocks')" \
79 | "YiiMP Directory:" "${YELLOW}$site${RESET}"
80 |
81 | print_header "Loop2:" "$(check_process_status 'loop2')" \
82 | "Hint:"" ${GREEN}To view a screen type, screen -r main|loop2|blocks|debug${RESET}"
83 |
84 | print_header "Debug:" "$(check_process_status 'log/debug.log')" \
85 | "Hint:"" ${GREEN}To detach from a screen type, ctrl+a+d${RESET}"
86 | echo
87 |
88 | # Server screens
89 | colored_message "Server screens:"
90 | echo -e "${YELLOW}To ${GREEN}Start${YELLOW} | ${RED}stop${YELLOW} | ${YELLOW}restart${YELLOW} | a screen use the following command.${RESET}"
91 | echo
92 | echo -e "${YELLOW}screens${GREEN} start ${YELLOW} |${RED} stop ${YELLOW} |${YELLOW} restart ${YELLOW} | main ${YELLOW} |loop2 ${YELLOW} | blocks ${YELLOW} | debug ${RESET}"
93 | echo
94 |
95 | # Reload hint
96 | colored_message "To reload this page just type: ${GREEN}motd${RESET}"
97 | echo
98 |
99 | # Donation information
100 | colored_message "Donations for continued support of this script are welcomed at:"
101 | echo "---------------------------------------------------------------"
102 | echo -e "BTC: ${CYAN} $BTCDON${RESET}"
103 | echo -e "DOGE: ${CYAN} $DOGEDON${RESET}"
104 | echo -e "ETH: ${CYAN} $ETHDON${RESET}"
105 | echo -e "LTC: ${CYAN} $LTCDON${RESET}"
106 | echo "---------------------------------------------------------------"
107 |
108 | # Display pending reboots and package updates
109 | /usr/lib/update-notifier/update-motd-reboot-required
110 | /usr/lib/update-notifier/apt-check --human-readable
111 | echo
112 |
--------------------------------------------------------------------------------
/yiimp_single/ubuntu/etc/update-motd.d/90-footer:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # 99-footer - write the admin's footer to the MOTD
4 | # Copyright (c) 2013 Nick Charlton
5 | # Copyright (c) 2009-2010 Canonical Ltd.
6 | #
7 | # Authors: Nick Charlton
8 | # Dustin Kirkland
9 | #
10 | # This program is free software; you can redistribute it and/or modify
11 | # it under the terms of the GNU General Public License as published by
12 | # the Free Software Foundation; either version 2 of the License, or
13 | # (at your option) any later version.
14 | #
15 | # This program is distributed in the hope that it will be useful,
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | # GNU General Public License for more details.
19 | #
20 | # You should have received a copy of the GNU General Public License along
21 | # with this program; if not, write to the Free Software Foundation, Inc.,
22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 | #####################################################
24 | # Updated by Afiniel for Yiimpool use...
25 | #####################################################
26 |
27 | [ -f /etc/motd.tail ] && cat /etc/motd.tail || true
28 |
--------------------------------------------------------------------------------
/yiimp_single/ubuntu/screens:
--------------------------------------------------------------------------------
1 | ############################################################################################################################
2 | # Source code from https://codereview.stackexchange.com/questions/55077/small-bash-script-to-start-and-stop-named-services #
3 | # Updated by Afiniel for Yiimpool use... #
4 | ############################################################################################################################
5 |
6 | source /etc/yiimpool.conf
7 | source $STORAGE_ROOT/yiimp/.prescreens.start.conf
8 | #!/bin/sh -e
9 |
10 | main="screen -dmS main ${CRONS}/main.sh"
11 | mainstop='screen -X -S main quit'
12 | loop2="screen -dmS loop2 ${CRONS}/loop2.sh"
13 | loop2quit='screen -X -S loop2 quit'
14 | blocks="screen -dmS blocks ${CRONS}/blocks.sh"
15 | blocksquit='screen -X -S blocks quit'
16 | debug="screen -dmS debug tail -f ${LOG_DIR}/debug.log"
17 | debugquit='screen -X -S debug quit'
18 |
19 | startstop_service() {
20 | cmd=$1
21 | name=$2
22 | sudo service $name $cmd
23 | }
24 |
25 | startstop_main() {
26 | cmd=$1
27 | case $cmd in
28 | stop) $mainstop ;;
29 | start) $main ;;
30 | restart)
31 | $mainstop
32 | sleep 1
33 | $main
34 | ;;
35 | esac
36 | }
37 |
38 | startstop_loop2() {
39 | cmd=$1
40 | case $cmd in
41 | stop) $loop2stop ;;
42 | start) $loop2 ;;
43 | restart)
44 | $loop2nstop
45 | sleep 1
46 | $loop2
47 | ;;
48 | esac
49 | }
50 |
51 | startstop_blocks() {
52 | cmd=$1
53 | case $cmd in
54 | stop) $blocksstop ;;
55 | start) $blocks ;;
56 | restart)
57 | $blocksstop
58 | sleep 1
59 | $blocks
60 | ;;
61 | esac
62 | }
63 |
64 | startstop_debug() {
65 | cmd=$1
66 | case $cmd in
67 | stop) $debugstop ;;
68 | start) $debug ;;
69 | restart)
70 | $debugstop
71 | sleep 1
72 | $debug
73 | ;;
74 | esac
75 | }
76 |
77 |
78 | case "$1" in
79 | start|stop|restart) cmd=$1 ;;
80 | *)
81 | shift
82 | servicenames=${@-servicenames}
83 | echo "usage: $0 [start|stop|restart] $servicenames"
84 | exit 1
85 | esac
86 | shift
87 |
88 | for name; do
89 | case "$name" in
90 | main) startstop_main $cmd ;;
91 | loop2) startstop_loop2 $cmd ;;
92 | blocks) startstop_blocks $cmd ;;
93 | debug) startstop_debug $cmd ;;
94 | *) startstop_service $cmd $name ;;
95 | esac
96 | done
--------------------------------------------------------------------------------
/yiimp_single/web.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox
5 | # Updated by afiniel for crypto use...
6 | #####################################################
7 |
8 | source /etc/functions.sh
9 | source /etc/yiimpool.conf
10 | source $STORAGE_ROOT/yiimp/.yiimp.conf
11 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
12 |
13 | set -eu -o pipefail
14 |
15 | function print_error {
16 | read line file <<<$(caller)
17 | echo "An error occurred in line $line of file $file:" >&2
18 | sed "${line}q;d" "$file" >&2
19 | }
20 | trap print_error ERR
21 | term_art
22 | if [[ ("$wireguard" == "true") ]]; then
23 | source $STORAGE_ROOT/yiimp/.wireguard.conf
24 | fi
25 |
26 | echo -e "$MAGENTA <--------------------------------------------------->$COL_RESET"
27 | echo -e "$MAGENTA <--$YELLOW Building web file structure and copying files$MAGENTA -->$COL_RESET"
28 | echo -e "$MAGENTA <--------------------------------------------------->$COL_RESET"
29 | echo
30 | echo -e "$CYAN => Building web file structure and copying files <= $COL_RESET"
31 |
32 | cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp
33 | sudo sed -i 's/myadmin/'${AdminPanel}'/' $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/web/yaamp/modules/site/SiteController.php
34 | sudo cp -r $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/web $STORAGE_ROOT/yiimp/site/
35 | cd $STORAGE_ROOT/yiimp/yiimp_setup/
36 | sudo cp -r $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/bin/. /bin/
37 | sudo mkdir -p /var/www/${DomainName}/html
38 | sudo mkdir -p /etc/yiimp
39 | sudo mkdir -p $STORAGE_ROOT/yiimp/site/backup/
40 | sudo sed -i "s|ROOTDIR=/data/yiimp|ROOTDIR=${STORAGE_ROOT}/yiimp/site|g" /bin/yiimp
41 |
42 | if [[ ("$UsingSubDomain" == "y" || "$UsingSubDomain" == "Y" || "$UsingSubDomain" == "yes" || "$UsingSubDomain" == "Yes" || "$UsingSubDomain" == "YES") ]]; then
43 | cd $HOME/yiimp_install_script/yiimp_single
44 | source nginx_subdomain_nonssl.sh
45 | if [[ ("$InstallSSL" == "y" || "$InstallSSL" == "Y" || "$InstallSSL" == "yes" || "$InstallSSL" == "Yes" || "$InstallSSL" == "YES") ]]; then
46 | cd $HOME/yiimp_install_script/yiimp_single
47 | source nginx_subdomain_ssl.sh
48 | fi
49 | else
50 | cd $HOME/yiimp_install_script/yiimp_single
51 | source nginx_domain_nonssl.sh
52 | if [[ ("$InstallSSL" == "y" || "$InstallSSL" == "Y" || "$InstallSSL" == "yes" || "$InstallSSL" == "Yes" || "$InstallSSL" == "YES") ]]; then
53 | cd $HOME/yiimp_install_script/yiimp_single
54 | source nginx_domain_ssl.sh
55 | fi
56 | fi
57 |
58 | echo
59 | echo -e "$MAGENTA => Creating YiiMP configuration files <= $COL_RESET"
60 | cd $HOME/yiimp_install_script/yiimp_single
61 | source yiimp_confs/keys.sh
62 | source yiimp_confs/yiimpserverconfig.sh
63 | source yiimp_confs/main.sh
64 | source yiimp_confs/loop2.sh
65 | source yiimp_confs/blocks.sh
66 | echo -e "$GREEN => Complete$COL_RESET"
67 |
68 | echo
69 | echo -e "$YELLOW => Setting correct folder permissions <= $COL_RESET"
70 | whoami=$(whoami)
71 | sudo usermod -aG www-data $whoami
72 | sudo usermod -a -G www-data $whoami
73 | sudo usermod -a -G crypto-data $whoami
74 | sudo usermod -a -G crypto-data www-data
75 |
76 | sudo find $STORAGE_ROOT/yiimp/site/ -type d -exec chmod 775 {} +
77 | sudo find $STORAGE_ROOT/yiimp/site/ -type f -exec chmod 664 {} +
78 |
79 | sudo chgrp www-data $STORAGE_ROOT -R
80 | sudo chmod g+w $STORAGE_ROOT -R
81 | echo -e "$GREEN => Complete$COL_RESET"
82 |
83 | cd $HOME/yiimp_install_script/yiimp_single
84 |
85 | #Updating YiiMP files for YiimPool build
86 | echo
87 | echo -e "$YELLOW => Adding the yiimpool flare to YiiMP <= $COL_RESET"
88 |
89 | sudo sed -i 's/YII MINING POOLS/'${DomainName}' Mining Pool/g' $STORAGE_ROOT/yiimp/site/web/yaamp/modules/site/index.php
90 | sudo sed -i 's/domain/'${DomainName}'/g' $STORAGE_ROOT/yiimp/site/web/yaamp/modules/site/index.php
91 | sudo sed -i 's/Notes/AddNodes/g' $STORAGE_ROOT/yiimp/site/web/yaamp/models/db_coinsModel.php
92 | sudo sed -i "s|serverconfig.php|${STORAGE_ROOT}/yiimp/site/configuration/serverconfig.php|g" $STORAGE_ROOT/yiimp/site/web/index.php
93 | sudo sed -i "s|serverconfig.php|${STORAGE_ROOT}/yiimp/site/configuration/serverconfig.php|g" $STORAGE_ROOT/yiimp/site/web/runconsole.php
94 | sudo sed -i "s|serverconfig.php|${STORAGE_ROOT}/yiimp/site/configuration/serverconfig.php|g" $STORAGE_ROOT/yiimp/site/web/run.php
95 | sudo sed -i "s|serverconfig.php|${STORAGE_ROOT}/yiimp/site/configuration/serverconfig.php|g" $STORAGE_ROOT/yiimp/site/web/yaamp/yiic.php
96 | sudo sed -i "s|serverconfig.php|${STORAGE_ROOT}/yiimp/site/configuration/serverconfig.php|g" $STORAGE_ROOT/yiimp/site/web/yaamp/modules/thread/CronjobController.php
97 | sudo sed -i "s|/root/backup|${STORAGE_ROOT}/yiimp/site/backup|g" $STORAGE_ROOT/yiimp/site/web/yaamp/core/backend/system.php
98 | sudo sed -i 's/service $webserver start/sudo service $webserver start/g' $STORAGE_ROOT/yiimp/site/web/yaamp/modules/thread/CronjobController.php
99 | sudo sed -i 's/service nginx stop/sudo service nginx stop/g' $STORAGE_ROOT/yiimp/site/web/yaamp/modules/thread/CronjobController.php
100 |
101 | if [[ ("$wireguard" == "true") ]]; then
102 | #Set Insternal IP to .0/26
103 | internalrpcip=$DBInternalIP
104 | internalrpcip="${DBInternalIP::-1}"
105 | internalrpcip="${internalrpcip::-1}"
106 | internalrpcip=$internalrpcip.0/26
107 | sudo sed -i '/# onlynet=ipv4/i\ echo "rpcallowip='${internalrpcip}'\\n";' $STORAGE_ROOT/yiimp/site/web/yaamp/modules/site/coin_form.php
108 | fi
109 |
110 | echo -e "$GREEN Web build complete$COL_RESET"
111 |
112 | set +eu +o pipefail
113 | cd $HOME/yiimp_install_script/yiimp_single
114 |
--------------------------------------------------------------------------------
/yiimp_single/wireguard.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##########################################
4 | # Created by Afiniel for Yiimpool use... #
5 | ##########################################
6 |
7 | # Load configuration files
8 | source "$HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf"
9 | source "$STORAGE_ROOT/yiimp/.wireguard.conf"
10 | source "/etc/functions.sh"
11 | source "/etc/yiimpool.conf"
12 |
13 | # Display banner
14 | term_art
15 | echo -e "$MAGENTA <-------------------------->$COL_RESET"
16 | echo -e "$MAGENTA <--$YELLOW Installing WireGuard$MAGENTA -->$COL_RESET"
17 | echo -e "$MAGENTA <-------------------------->$COL_RESET"
18 |
19 | # Add WireGuard repository and install packages
20 | sudo add-apt-repository ppa:wireguard/wireguard -y
21 | sudo apt-get update -y
22 | sudo apt-get install wireguard-dkms wireguard-tools -y
23 |
24 | # Generate WireGuard keys
25 | wg_private_key=$(wg genkey)
26 | wg_public_key=$(echo "$wg_private_key" | wg pubkey)
27 |
28 | # Create WireGuard configuration file
29 | wg_config="/etc/wireguard/wg0.conf"
30 | sudo tee "$wg_config" >/dev/null </dev/null 2>&1
49 |
50 | echo
51 | echo -e "$GREEN WireGuard setup completed $COL_RESET"
52 |
53 | # Change directory to yiimp_single
54 | cd "$HOME/yiimpool/yiimp_single"
55 |
--------------------------------------------------------------------------------
/yiimp_single/yiimp_confs/blocks.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #########################################
4 | # Created by Afiniel for Yiimpool use...#
5 | #########################################
6 |
7 | source /etc/functions.sh
8 | source /etc/yiimpool.conf
9 | source $STORAGE_ROOT/yiimp/.yiimp.conf
10 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
11 |
12 | #Create blocks.sh
13 |
14 | echo '#!/usr/bin/env bash
15 | PHP_CLI='"'"''"php -d max_execution_time=60"''"'"'
16 | DIR='""''"${STORAGE_ROOT}"''""'/yiimp/site/web/
17 | cd ${DIR}
18 | date
19 | echo started in ${DIR}
20 | while true; do
21 | ${PHP_CLI} runconsole.php cronjob/runBlocks
22 | sleep 20
23 | done
24 | exec bash' | sudo -E tee $STORAGE_ROOT/yiimp/site/crons/blocks.sh >/dev/null 2>&1
25 | sudo chmod +x $STORAGE_ROOT/yiimp/site/crons/blocks.sh
26 |
27 | cd $HOME/yiimp_install_script/yiimp_single
--------------------------------------------------------------------------------
/yiimp_single/yiimp_confs/exbitron_trading.php:
--------------------------------------------------------------------------------
1 | 0)||($onsell>0))
43 | {
44 | echo 'Method Symbol => ' .$symbol. ' Balance ' .$amount. ' Lock ' .$onsell;
45 | echo "\n";
46 | }
47 | if ($symbol == 'BTC')
48 | {
49 | echo "Update BTC Balance\n";
50 | $sql = "UPDATE balances SET balance=$amount WHERE `name`='$exchange';";
51 | $result_update = $mysqli->query($sql);
52 |
53 | //Auto Witddraw
54 | // $withdraw_min = EXCH_AUTO_WITHDRAW;
55 | // $withdraw_fee = 0.0015;
56 | // $balance = $amount;
57 | // if(floatval($withdraw_min) > 0 && $balance >= ($withdraw_min + $withdraw_fee))
58 | // {
59 | // $btcaddr = YAAMP_BTCADDRESS;
60 | // $withdraw_fee = 0.0015;
61 | // if(floatval($withdraw_min) > 0 && $balance >= ($withdraw_min + $withdraw_fee))
62 | // {
63 | // echo "===== Auto Withdraw ====\n";
64 | // $btcaddr = YAAMP_BTCADDRESS;
65 | // $amount = $balace - $withdraw_fee;
66 | // echo "$exchange: withdraw $amount BTC to $btcaddr\n";
67 |
68 | // //count_delay($dtime);
69 | // $params = array("currency"=>"btc", "amount"=>$amount, "rid"=>$btcaddr);
70 | // $result = graviex_api_query_post('create_withdraw.json', $params);
71 | // print_r ($result);
72 | // echo "Reset Balance\n";
73 | // $sql = "UPDATE balances SET balance=0 WHERE `name`='$exchange';";
74 | // $result = $mysqli->query($sql);
75 | // }
76 | // }
77 | } else if (($symbol == 'DOGE')||($symbol == 'LTC')) {
78 | echo "Update DOGE Balance\n";
79 | $sql = "UPDATE markets SET balance=$amount,ontrade=$onsell,lasttraded=UNIX_TIMESTAMP() WHERE `name`='$exchange' AND coinid=(SELECT id FROM coins WHERE symbol = '$symbol');";
80 | $result_update = $mysqli->query($sql);
81 | }
82 | else
83 | {
84 | //Check Balance and create Order
85 | #if ($amount>1)
86 | {
87 | $sql = "SELECT * FROM coins WHERE symbol='$symbol' AND dontsell=0";
88 | $result = $mysqli->query($sql);
89 | if ($result->num_rows>0)
90 | {
91 | $coin = $result->fetch_object();
92 | echo $coin->symbol. "\n";
93 |
94 | //Update Balance
95 | $sql = "UPDATE markets SET balance=$amount,ontrade=$onsell,lasttraded=UNIX_TIMESTAMP() WHERE `name`='$exchange' AND coinid=$coin->id;";
96 | $result_update = $mysqli->query($sql);
97 |
98 | $uri = strtolower($coin->symbol).'btc';
99 | $ticker = exbitron_api_query("markets/tickers");
100 | $sellamount = min(5000,bitcoinvaluetoa($amount));
101 |
102 | if ($coin->sellonbid)
103 | $sellprice = $ticker["ticker"]["low"];
104 | else
105 | $sellprice = $ticker["ticker"]["high"];
106 |
107 | $limit_price = $amount * $sellprice;
108 |
109 | if ($limit_price>$min_sell_price)
110 | {
111 | echo "Sell $symbol";
112 |
113 | $params = array('market' => strtolower($symbol).'btc', 'side' => 'sell', 'price' => $sellprice, 'volume' => $sellamount);
114 | print_r ($params);
115 | $res = exbitron_api_post('market/orders', $params);
116 | print_r ($res);
117 | #$res = json_decode($res,true);
118 | // if (isset($res->error))
119 | // {
120 | // $message = $res->error->message;
121 | // if ((strpos($message,"Fee")!==false) || (strpos($message,"CreateOrderError")!==false))
122 | // {
123 | // $sql = "UPDATE markets SET message='$message',lasttraded=UNIX_TIMESTAMP(),message='$message' WHERE `name`='$exchange' AND coinid=$coin->id;";
124 | // $result_update = $mysqli->query($sql);
125 |
126 | // }
127 | // else
128 | // {
129 | // system('mail "' .$exchange. ' ' .$symbol. ' ' .$message. '"');
130 | // $sql = "UPDATE markets SET message='$message' WHERE `name`='$exchange' AND coinid=$coin->id;";
131 | // #echo $sql;
132 | // $result_update = $mysqli->query($sql);
133 | // }
134 | // }
135 | // else
136 | // {
137 | // $sql = "UPDATE markets SET lasttraded=UNIX_TIMESTAMP() WHERE `name`='$exchange' AND coinid=$coin->id;";
138 | // $result_update = $mysqli->query($sql);
139 | // }
140 | count_delay($dtime);
141 |
142 |
143 | }
144 |
145 | }
146 | }
147 |
148 | // Get Deposit Addresss
149 | $sql = "SELECT * FROM markets WHERE `name`='$exchange' AND coinid IN (SELECT id FROM coins WHERE (symbol='$symbol' OR symbol2='$symbol'))";
150 | $result_market = $mysqli->query($sql);
151 | if ($result_market->num_rows>0)
152 | {
153 | $market = $result_market->fetch_object();
154 | // if ($market->deposit_address=="")
155 | {
156 | echo "Get Deposit Address: $symbol\n";
157 | $res = exbitron_api_get('account/deposit_address/' .strtolower($symbol));
158 | // print_r ($res);
159 | $address = $res['address'];
160 | if ($market->deposit_address!=$address) {
161 | echo "Update Deposite Address to $address\n";
162 | $sql = "UPDATE markets SET deposit_address='$address' WHERE `name`='$exchange' AND coinid IN (SELECT id FROM coins WHERE (symbol='$symbol' OR symbol2='$symbol'));";
163 | $result_update = $mysqli->query($sql);
164 | }
165 | }
166 |
167 | }
168 | }
169 | }
170 |
171 |
172 | }
173 | /*
174 | function exbitron_api_query($method)
175 | {
176 | $uri = "https://www.exbitron.com/api/v2/peatio/public/$method";
177 | $ch = curl_init($uri);
178 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
179 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
180 | curl_setopt($ch, CURLOPT_TIMEOUT, 30);
181 | $res = curl_exec($ch);
182 | $obj = json_decode($res,true);
183 | return $obj;
184 | }
185 | */
186 | function exbitron_api_get($method, $req = array())
187 | {
188 | // echo __METHOD__;
189 | require_once('/etc/yiimp/keys.php');
190 | $uri = "https://www.exbitron.com/api/v2/peatio/$method";
191 |
192 | $reqStr=print_r($req, true);
193 | sleep(1);
194 |
195 | // optional secret key
196 | if (empty(EXCH_EXBITRON_SECRET) && strpos($method, 'public') === FALSE) return FALSE;
197 | if (empty(EXCH_EXBITRON_KEY) && strpos($method, 'public') === FALSE) return FALSE;
198 |
199 | $req = auth();
200 |
201 | $ch = curl_init($uri);
202 | curl_setopt($ch, CURLOPT_HTTPHEADER, $req);
203 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
204 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
205 | curl_setopt($ch, CURLOPT_TIMEOUT, 30);
206 | curl_setopt($ch, CURLOPT_POST, false);
207 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
208 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
209 | $execResult = curl_exec($ch);
210 |
211 |
212 | $resData = json_decode($execResult,true);
213 |
214 | return $resData;
215 | }
216 |
217 | function exbitron_api_post($method, $postData = array())
218 | {
219 | // echo __METHOD__;
220 | require_once('/etc/yiimp/keys.php');
221 | $uri = "https://www.exbitron.com/api/v2/peatio/$method";
222 |
223 | // optional secret key
224 | if (empty(EXCH_EXBITRON_SECRET) && strpos($method, 'public') === FALSE) return FALSE;
225 | if (empty(EXCH_EXBITRON_KEY) && strpos($method, 'public') === FALSE) return FALSE;
226 |
227 | $req = auth();
228 |
229 | $ch = curl_init($uri);
230 | curl_setopt($ch, CURLOPT_HTTPHEADER, $req);
231 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
232 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
233 | curl_setopt($ch, CURLOPT_TIMEOUT, 30);
234 | curl_setopt($ch, CURLOPT_POST, true);
235 | curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
236 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
237 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
238 | $execResult = curl_exec($ch);
239 |
240 | $resData = json_decode($execResult,true);
241 |
242 | return $resData;
243 | }
244 |
245 | function auth() {
246 | require_once('/etc/yiimp/keys.php');
247 |
248 | $apikey = EXCH_EXBITRON_KEY; // your API-key
249 | $apisecret = EXCH_EXBITRON_SECRET; // your Secret-key
250 |
251 | $nonce = time()*1000;
252 | $sign = hash_hmac('sha256', $nonce. '' .$apikey, $apisecret);
253 |
254 | $req = array();
255 | $req[] = "X-Auth-Apikey: $apikey";
256 | $req[] = "X-Auth-Nonce: $nonce";
257 | $req[] = "X-Auth-Signature: $sign";
258 |
259 | return $req;
260 | }
261 |
262 |
263 | function endsWith($name,$match)
264 | {
265 | $match_len = strlen($match)*(-1);
266 | if (substr($name,$match_len)==$match)
267 | {
268 | return true;
269 | }
270 | else
271 | {
272 | return false;
273 | }
274 | }
275 |
276 |
277 |
278 | function mysql_connect()
279 | {
280 | echo "Mysql Connect\n";
281 | $mysqli = new mysqli(YAAMP_DBHOST, YAAMP_DBUSER, YAAMP_DBPASSWORD,YAAMP_DBNAME);
282 | if ($mysqli->connect_errno) {
283 | echo "Error: Unable to connect to MySQL." . PHP_EOL;
284 | echo "Debugging errno: " .$mysqli->connect_error. PHP_EOL;
285 | exit;
286 | }
287 | echo "Connected successfully\n";
288 | return $mysqli;
289 | }
290 |
291 | function count_delay($time=1)
292 | {
293 | for ($i=1;$i<=$time;$i++)
294 | {
295 | //echo "Delay Time = " .$i. "\n";
296 | sleep(1);
297 | }
298 | }
299 |
300 |
301 | ?>
--------------------------------------------------------------------------------
/yiimp_single/yiimp_confs/keys.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Created by Afiniel for Yiimpool use...
5 | #####################################################
6 |
7 | source /etc/functions.sh
8 | source /etc/yiimpool.conf
9 | source $STORAGE_ROOT/yiimp/.yiimp.conf
10 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
11 |
12 | #Create keys file
13 | echo '/dev/null 2>&1
52 | cd $HOME/yiimp_install_script/yiimp_single
53 |
--------------------------------------------------------------------------------
/yiimp_single/yiimp_confs/loop2.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #########################################
4 | # Created by Afiniel for Yiimpool use...#
5 | #########################################
6 |
7 | source /etc/functions.sh
8 | source /etc/yiimpool.conf
9 | source $STORAGE_ROOT/yiimp/.yiimp.conf
10 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
11 |
12 | # Create loop2.sh
13 |
14 | echo '#!/usr/bin/env bash
15 | PHP_CLI='"'"''"php -d max_execution_time=120"''"'"'
16 | DIR='""''"${STORAGE_ROOT}"''""'/yiimp/site/web/
17 | cd ${DIR}
18 | date
19 | echo started in ${DIR}
20 | while true; do
21 | ${PHP_CLI} runconsole.php cronjob/runLoop2
22 | sleep 60
23 | done
24 | exec bash' | sudo -E tee $STORAGE_ROOT/yiimp/site/crons/loop2.sh >/dev/null 2>&1
25 | sudo chmod +x $STORAGE_ROOT/yiimp/site/crons/loop2.sh
26 | cd $HOME/yiimp_install_script/yiimp_single
27 |
--------------------------------------------------------------------------------
/yiimp_single/yiimp_confs/main.php:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | END;
17 |
18 | $pageTitle = empty($this->pageTitle) ? YAAMP_SITE_NAME : YAAMP_SITE_NAME." - ".$this->pageTitle;
19 |
20 | echo ''.$pageTitle.'';
21 |
22 | echo CHtml::cssFile("/extensions/jquery/themes/ui-lightness/jquery-ui.css");
23 | echo CHtml::cssFile('/yaamp/ui/css/main.css');
24 | echo CHtml::cssFile('/yaamp/ui/css/table.css');
25 |
26 | //echo CHtml::scriptFile('/extensions/jquery/js/jquery-1.8.3-dev.js');
27 | //echo CHtml::scriptFile('/extensions/jquery/js/jquery-ui-1.9.1.custom.min.js');
28 |
29 | $cs = app()->getClientScript();
30 | $cs->registerCoreScript('jquery.ui');
31 | //$cs->registerScriptFile('/yaamp/ui/js/jquery.tablesorter.js', CClientScript::POS_END);
32 |
33 | echo CHtml::scriptFile('/yaamp/ui/js/jquery.tablesorter.js');
34 |
35 | // if(!controller()->admin)
36 | // echo <<
38 | // (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
39 | // (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
40 | // m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
41 | // })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
42 |
43 | // ga('create', 'UA-58136019-1', 'auto');
44 | // ga('send', 'pageview');
45 |
46 | // $(document).ajaxSuccess(function(){ga('send', 'pageview');});
47 |
48 | //
49 | // end;
50 |
51 | echo "";
52 |
53 | ///////////////////////////////////////////////////////////////
54 |
55 | echo '';
56 | echo 'main';
57 |
58 | showPageHeader();
59 | showPageContent($content);
60 | showPageFooter();
61 |
62 | echo "";
63 | return;
64 |
65 | /////////////////////////////////////////////////////////////////////
66 |
67 | function showItemHeader($selected, $url, $name)
68 | {
69 | if($selected) $selected_text = "class='selected'";
70 | else $selected_text = '';
71 |
72 | echo "$name";
73 | echo " ";
74 | }
75 |
76 | function showPageHeader()
77 | {
78 | echo '";
132 | }
133 |
134 | function showPageFooter()
135 | {
136 | echo '';
143 | }
144 |
--------------------------------------------------------------------------------
/yiimp_single/yiimp_confs/main.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #########################################
4 | # Created by Afiniel for Yiimpool use...#
5 | #########################################
6 |
7 | source /etc/functions.sh
8 | source /etc/yiimpool.conf
9 | source $STORAGE_ROOT/yiimp/.yiimp.conf
10 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
11 |
12 | # Create main.sh
13 | echo '#!/usr/bin/env bash
14 | PHP_CLI='"'"''"php -d max_execution_time=120"''"'"'
15 | DIR='""''"${STORAGE_ROOT}"''""'/yiimp/site/web/
16 | cd ${DIR}
17 | date
18 | echo started in ${DIR}
19 | while true; do
20 | ${PHP_CLI} runconsole.php cronjob/run
21 | sleep 90
22 | done
23 | exec bash' | sudo -E tee $STORAGE_ROOT/yiimp/site/crons/main.sh >/dev/null 2>&1
24 | sudo chmod +x $STORAGE_ROOT/yiimp/site/crons/main.sh
25 |
26 | cd $HOME/yiimp_install_script/yiimp_single
27 |
--------------------------------------------------------------------------------
/yiimp_single/yiimp_confs/yiimpserverconfig.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #####################################################
4 | # Created by Afiniel for Yiimpool use...
5 | #####################################################
6 |
7 | source /etc/functions.sh
8 | source /etc/yiimpool.conf
9 | source $STORAGE_ROOT/yiimp/.yiimp.conf
10 | source $HOME/yiimp_install_script/yiimp_single/.wireguard.install.cnf
11 |
12 | if [[ ("$wireguard" == "false") ]]; then
13 |
14 | echo ' 0.3
54 | define('"'"'EXCH_AUTO_WITHDRAW'"'"', 0.3);
55 |
56 | // nicehash keys deposit account & amount to deposit at a time
57 | define('"'"'NICEHASH_API_KEY'"'"','"'"'521c254d-8cc7-4319-83d2-ac6c604b5b49'"'"');
58 | define('"'"'NICEHASH_API_ID'"'"','"'"'9205'"'"');
59 | define('"'"'NICEHASH_DEPOSIT'"'"','"'"'3J9tapPoFCtouAZH7Th8HAPsD8aoykEHzk'"'"');
60 | define('"'"'NICEHASH_DEPOSIT_AMOUNT'"'"','"'"'0.01'"'"');
61 | $cold_wallet_table = array(
62 | '"'"'bc1qpnxtg3dvtglrvfllfk3gslt6h5zffkf069nh8r'"'"' => 0.10,
63 |
64 | );
65 | // Sample fixed pool fees
66 | $configFixedPoolFees = array(
67 | '"'"'zr5'"'"' => 2.0,
68 | '"'"'scrypt'"'"' => 20.0,
69 | '"'"'sha256'"'"' => 5.0,
70 | );
71 | // Sample fixed pool fees solo , With 1.5 default set.
72 | $configFixedPoolFeesSolo = array(
73 | '"'"'zr5'"'"' => 1.5,
74 | '"'"'scrypt'"'"' => 1.5,
75 | '"'"'sha256'"'"' => 1.5,
76 | );
77 | // Sample custom stratum ports
78 | $configCustomPorts = array(
79 | // '"'"'x11'"'"' => 7000,
80 | );
81 | // mBTC Coefs per algo (default is 1.0)
82 | $configAlgoNormCoef = array(
83 | // '"'"'x11'"'"' => 5.0,
84 | );' | sudo -E tee $STORAGE_ROOT/yiimp/site/configuration/serverconfig.php >/dev/null 2>&1
85 |
86 | else
87 |
88 | echo ' 0.3
127 | define('"'"'EXCH_AUTO_WITHDRAW'"'"', 0.3);
128 |
129 | // nicehash keys deposit account & amount to deposit at a time
130 | define('"'"'NICEHASH_API_KEY'"'"','"'"'521c254d-8cc7-4319-83d2-ac6c604b5b49'"'"');
131 | define('"'"'NICEHASH_API_ID'"'"','"'"'9205'"'"');
132 | define('"'"'NICEHASH_DEPOSIT'"'"','"'"'3J9tapPoFCtouAZH7Th8HAPsD8aoykEHzk'"'"');
133 | define('"'"'NICEHASH_DEPOSIT_AMOUNT'"'"','"'"'0.01'"'"');
134 |
135 | $cold_wallet_table = array(
136 | '"'"'bc1qpnxtg3dvtglrvfllfk3gslt6h5zffkf069nh8r'"'"' => 0.10,
137 | );
138 |
139 | // Sample fixed pool fees
140 | $configFixedPoolFees = array(
141 | '"'"'zr5'"'"' => 2.0,
142 | '"'"'scrypt'"'"' => 20.0,
143 | '"'"'sha256'"'"' => 5.0,
144 | );
145 | // Sample fixed pool fees solo , With 1.5 default set.
146 | $configFixedPoolFeesSolo = array(
147 | '"'"'zr5'"'"' => 1.5,
148 | '"'"'scrypt'"'"' => 1.5,
149 | '"'"'sha256'"'"' => 1.5,
150 | );
151 |
152 | // Sample custom stratum ports
153 | $configCustomPorts = array(
154 | // '"'"'x11'"'"' => 7000,
155 | );
156 |
157 | // mBTC Coefs per algo (default is 1.0)
158 | $configAlgoNormCoef = array(
159 | // '"'"'x11'"'"' => 5.0,
160 | );' | sudo -E tee $STORAGE_ROOT/yiimp/site/configuration/serverconfig.php >/dev/null 2>&1
161 | fi
162 | cd $HOME/yiimp_install_script/yiimp_single
163 |
--------------------------------------------------------------------------------
/yiimp_upgrade/menu.sh:
--------------------------------------------------------------------------------
1 | #!/bin/env bash
2 |
3 | #
4 | # This is the main menu
5 | #
6 | # Author: Afiniel
7 | #
8 | # Updated: 2023-03-16
9 | #
10 |
11 | source /etc/yiimpooldonate.conf
12 | source /etc/functions.sh
13 |
14 | RESULT=$(dialog --stdout --default-item 1 --title "YiimPool Yiimp Upgrader $VERSION" --menu "choose an option" -1 55 7 \
15 | ' ' "- Do you want to upgrade Yiimp Stratum? -" \
16 | 1 "Yes" \
17 | 2 exit)
18 |
19 | if [ "$RESULT" = "1" ]; then
20 | clear;
21 | cd $HOME/yiimp_install_script/yiimp_upgrade
22 | source single.sh
23 |
24 | elif [ "$RESULT" = "2" ]; then
25 | clear;
26 | echo "You have chosen to exit the Yiimp Upgrader. Type: yiimpool anytime to start the menu again.";
27 | exit;
28 | fi
--------------------------------------------------------------------------------
/yiimp_upgrade/single.sh:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Created by afiniel for crypto use...
3 | #####################################################
4 |
5 | source /etc/functions.sh
6 | source /etc/yiimpool.conf
7 | source $STORAGE_ROOT/yiimp/.yiimp.conf
8 |
9 | if [[ ! -e '$STORAGE_ROOT/yiimp/yiimp_setup/yiimp' ]]; then
10 | sudo rm -r $STORAGE_ROOT/yiimp/yiimp_setup/yiimp
11 | sudo git clone ${YiiMPRepo} $STORAGE_ROOT/yiimp/yiimp_setup/yiimp
12 | else
13 | sudo git clone ${YiiMPRepo} $STORAGE_ROOT/yiimp/yiimp_setup/yiimp
14 | fi
15 |
16 | echo -e "$CYAN Updating Stratum... $COL_RESET"
17 |
18 | # Compil Stratum
19 | cd /home/crypto-data/yiimp/yiimp_setup/yiimp/stratum
20 |
21 | sudo git submodule init && sudo git submodule update
22 | sudo make -C algos
23 | sudo make -C sha3
24 | sudo make -C iniparser
25 | cd secp256k1 && sudo chmod +x autogen.sh && sudo ./autogen.sh && sudo ./configure --enable-experimental --enable-module-ecdh --with-bignum=no --enable-endomorphism && sudo make -j$((`nproc`+1))
26 | if [[ ("$AutoExchange" == "y" || "$AutoExchange" == "Y" || "$AutoExchange" == "yes" || "$AutoExchange" == "Yes" || "$AutoExchange" == "YES") ]]; then
27 | sudo sed -i 's/CFLAGS += -DNO_EXCHANGE/#CFLAGS += -DNO_EXCHANGE/' /home/crypto-data/yiimp/yiimp_setup/yiimp/stratum/Makefile
28 | fi
29 |
30 | cd /home/crypto-data/yiimp/yiimp_setup/yiimp/stratum
31 | sudo make -j$((`nproc`+1))
32 |
33 | sudo mv stratum $STORAGE_ROOT/yiimp/site/stratum
34 |
35 | cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/web/yaamp/core/functions/
36 | cp -r yaamp.php $STORAGE_ROOT/yiimp/site/web/yaamp/core/functions
37 |
38 | echo -e "$YELLOW Stratum build$GREEN complete... $COL_RESET"
39 | cd $HOME/yiimp_install_script/yiimp_upgrade
40 |
--------------------------------------------------------------------------------
/yiimp_upgrade/start.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 |
4 | #####################################################
5 | # This is the entry point for configuring the system.
6 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox
7 | # Updated by afiniel for crypto use...
8 | #####################################################
9 |
10 | source /etc/functions.sh # load our functions
11 | source /etc/yiimpool.conf
12 | # Ensure Python reads/writes files in UTF-8. If the machine
13 | # triggers some other locale in Python, like ASCII encoding,
14 | # Python may not be able to read/write files. This is also
15 | # in the management daemon startup script and the cron script.
16 |
17 | if ! locale -a | grep en_US.utf8 > /dev/null; then
18 | # Generate locale if not exists
19 | hide_output locale-gen en_US.UTF-8
20 | fi
21 |
22 | export LANGUAGE=en_US.UTF-8
23 | export LC_ALL=en_US.UTF-8
24 | export LANG=en_US.UTF-8
25 | export LC_TYPE=en_US.UTF-8
26 |
27 | # Fix so line drawing characters are shown correctly in Putty on Windows. See #744.
28 | export NCURSES_NO_UTF8_ACS=1
29 |
30 | # Create the temporary installation directory if it doesn't already exist.
31 | echo Creating the temporary YiiMP installation folder...
32 | if [ ! -d $STORAGE_ROOT/yiimp/yiimp_setup ]; then
33 | sudo mkdir -p $STORAGE_ROOT/yiimp/yiimp_setup
34 | fi
35 |
36 | # Start the installation.
37 | source $STORAGE_ROOT/yiimp/.yiimp.conf
38 | source upgrade_warning.sh
39 | source menu.sh
40 |
41 | clear
42 | echo -e "$YELLOW Upgrade of your YiiMP stratum is now$GREEN completed. $COL_RESET"
43 |
--------------------------------------------------------------------------------
/yiimp_upgrade/up_stratum.sh:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Created by afiniel for crypto use...
3 | #####################################################
4 |
5 | source /etc/functions.sh
6 | source /etc/yiimpool.conf
7 | source $STORAGE_ROOT/yiimp/.yiimp.conf
8 |
9 | if [[ ! -e '$STORAGE_ROOT/yiimp/yiimp_setup/yiimp' ]]; then
10 | sudo rm -r $STORAGE_ROOT/yiimp/yiimp_setup/yiimp
11 | hide_output sudo git clone ${YiiMPRepo} $STORAGE_ROOT/yiimp/yiimp_setup/yiimp
12 | else
13 | hide_output sudo git clone ${YiiMPRepo} $STORAGE_ROOT/yiimp/yiimp_setup/yiimp
14 | fi
15 |
16 | echo -e "$YELLOW Upgrading stratum... $COL_RESET"
17 | cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/stratum/iniparser
18 | hide_output make -j$((`nproc`+1))
19 |
20 | cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/stratum
21 | if [[ ("$AutoExchange" == "y" || "$AutoExchange" == "Y" || "$AutoExchange" == "yes" || "$AutoExchange" == "Yes" || "$AutoExchange" == "YES") ]]; then
22 | sudo sed -i 's/CFLAGS += -DNO_EXCHANGE/#CFLAGS += -DNO_EXCHANGE/' $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/stratum/Makefile
23 | fi
24 | hide_output make -j$((`nproc`+1))
25 |
26 | cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/stratum
27 | sudo mv stratum $STORAGE_ROOT/yiimp/site/stratum
28 |
29 | echo "Stratum build complete..."
30 | cd $HOME/yiimp_install_script/yiimp_upgrade
31 |
--------------------------------------------------------------------------------
/yiimp_upgrade/up_web.sh:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Created by afiniel for crypto use...
3 | #####################################################
4 |
5 | source /etc/functions.sh
6 | source /etc/yiimpool.conf
7 | source $STORAGE_ROOT/yiimp/.yiimp.conf
8 |
9 | if [[ ! -e '$STORAGE_ROOT/yiimp/yiimp_setup/yiimp' ]]; then
10 | sudo rm -r $STORAGE_ROOT/yiimp/yiimp_setup/yiimp
11 | hide_output sudo git clone ${YiiMPRepo} $STORAGE_ROOT/yiimp/yiimp_setup/yiimp
12 | else
13 | hide_output sudo git clone ${YiiMPRepo} $STORAGE_ROOT/yiimp/yiimp_setup/yiimp
14 | fi
15 |
16 | echo Upgrading stratum...
17 | cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/web/yaamp/core/functions/
18 |
19 | cp -r yaamp.php $STORAGE_ROOT/yiimp/site/web/yaamp/core/functions
20 |
21 | echo "Web upgrade complete..."
22 | cd $HOME/yiimp_install_script/yiimp_upgrade
23 |
--------------------------------------------------------------------------------
/yiimp_upgrade/upgrade_warning.sh:
--------------------------------------------------------------------------------
1 | #####################################################
2 | # Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox
3 | # Updated by afiniel for crypto use...
4 | #####################################################
5 |
6 | message_box "Yiimpool Stratum upgrade" \
7 | "You have choosen to upgrade your YiiMP server(s)!
8 | \n\nWith so many custom YiiMP installations out there, this installer will ONLY upgrade the required stratum files.
9 | \n\n
10 | \n\nThis upgrade also will NOT copy any example.stratum.conf files to /home/crypto-data/yiimp/site/stratum/config.
11 | \n\nThis is done to prevent any overwrites of dedicated port configs you may have.
12 | \n\nIf you need a config file for a new Algo, please visit our github for the example.
13 | \n\n
14 | \n\nThis updater has two parts that needs to be ran, the first is on your stratum server(s) and the second on your web server.
15 | \n\nThe web server portion will only update the file web/yaamp/core/functions/yaamp.php."
16 |
--------------------------------------------------------------------------------