Merge pull request #1985 from Emzy/ops/install-linux-crontab
Add crontab creation for linux and bitcoin-minfee.service in prod install
This commit is contained in:
		
						commit
						81c68620a1
					
				| @ -41,6 +41,7 @@ ELEMENTS_INSTALL=ON | ||||
| 
 | ||||
| # configure 4 network instances | ||||
| BITCOIN_MAINNET_ENABLE=ON | ||||
| BITCOIN_MAINNET_MINFEE_ENABLE=ON | ||||
| BITCOIN_TESTNET_ENABLE=ON | ||||
| BITCOIN_SIGNET_ENABLE=ON | ||||
| BISQ_MAINNET_ENABLE=ON | ||||
| @ -684,6 +685,7 @@ $CUT >$input <<-EOF | ||||
| Tor:Enable Tor v3 HS Onion:ON | ||||
| Certbot:Enable HTTPS using Certbot:ON | ||||
| Mainnet:Enable Bitcoin Mainnet:ON | ||||
| Mainnet-Minfee:Enable Bitcoin Mainnet Minfee:ON | ||||
| Testnet:Enable Bitcoin Testnet:ON | ||||
| Liquid:Enable Elements Liquid:ON | ||||
| Bisq:Enable Bisq:ON | ||||
| @ -727,6 +729,12 @@ else | ||||
|     BITCOIN_MAINNET_ENABLE=OFF | ||||
| fi | ||||
| 
 | ||||
| if grep Mainnet-Minfee $tempfile >/dev/null 2>&1;then | ||||
|     BITCOIN_MAINNET_MINFEE_ENABLE=ON | ||||
| else | ||||
|     BITCOIN_MAINNET_MINFEE_ENABLE=OFF | ||||
| fi | ||||
| 
 | ||||
| if grep Testnet $tempfile >/dev/null 2>&1;then | ||||
|     BITCOIN_TESTNET_ENABLE=ON | ||||
| else | ||||
| @ -1207,6 +1215,24 @@ if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then | ||||
|     esac | ||||
| fi | ||||
| 
 | ||||
| ####################################### | ||||
| # Bitcoin instance for Mainnet Minfee # | ||||
| ####################################### | ||||
| 
 | ||||
| if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then | ||||
|     echo "[*] Installing Bitcoin Minfee service" | ||||
|     case $OS in | ||||
| 
 | ||||
|         FreeBSD) | ||||
|             echo "[*] FIXME: Bitcoin Minfee service must be installed manually on FreeBSD" | ||||
|         ;; | ||||
| 
 | ||||
|         Debian) | ||||
|             osSudo "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/linux/bitcoin-minfee.service" "${DEBIAN_SERVICE_HOME}" | ||||
|         ;; | ||||
|     esac | ||||
| fi | ||||
| 
 | ||||
| ################################ | ||||
| # Bitcoin instance for Testnet # | ||||
| ################################ | ||||
| @ -1270,9 +1296,16 @@ if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then | ||||
|     osSudo "${ROOT_USER}" install -c -o "${BITCOIN_USER}" -g "${BITCOIN_GROUP}" -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/electrs-start-mainnet" "${BITCOIN_ELECTRS_HOME}" | ||||
| 
 | ||||
|     echo "[*] Installing Bitcoin crontab" | ||||
|     # FIXME: must only crontab enabled daemons | ||||
|     osSudo "${ROOT_USER}" crontab -u "${BITCOIN_USER}" "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/bitcoin.crontab" | ||||
|     osSudo "${ROOT_USER}" crontab -u "${MINFEE_USER}" "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/minfee.crontab" | ||||
|     case $OS in | ||||
|         FreeBSD) | ||||
|             echo [*] FIXME: must only crontab enabled daemons | ||||
|             osSudo "${ROOT_USER}" crontab -u "${BITCOIN_USER}" "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/bitcoin.crontab" | ||||
|             osSudo "${ROOT_USER}" crontab -u "${MINFEE_USER}" "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/minfee.crontab" | ||||
|         ;; | ||||
|         Debian) | ||||
|             (crontab -l ; echo "@reboot sleep 30 ; screen -dmS mainnet /bitcoin/electrs/electrs-start-mainnet") | osSudo "${ROOT_USER}" crontab -u "${BITCOIN_USER}" - | ||||
|         ;; | ||||
|     esac | ||||
| 
 | ||||
|     echo "[*] Configuring Bitcoin Mainnet RPC credentials in electrs start script" | ||||
|     osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${BITCOIN_ELECTRS_HOME}/electrs-start-mainnet" | ||||
| @ -1288,6 +1321,13 @@ if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then | ||||
|     echo "[*] Installing Bitcoin Testnet electrs start script" | ||||
|     osSudo "${ROOT_USER}" install -c -o "${BITCOIN_USER}" -g "${BITCOIN_GROUP}" -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/electrs-start-testnet" "${BITCOIN_ELECTRS_HOME}" | ||||
| 
 | ||||
|     case $OS in | ||||
|         Debian) | ||||
|             echo "[*] Installing Bitcoin-testnet crontab" | ||||
|             (crontab -l ; echo "@reboot sleep 70 ; screen -dmS testnet /bitcoin/electrs/electrs-start-testnet") | osSudo "${ROOT_USER}" crontab -u "${BITCOIN_USER}" - | ||||
|         ;; | ||||
|     esac | ||||
| 
 | ||||
|     echo "[*] Configuring Bitcoin Testnet RPC credentials in electrs start script" | ||||
|     osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${BITCOIN_ELECTRS_HOME}/electrs-start-testnet" | ||||
|     osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${BITCOIN_ELECTRS_HOME}/electrs-start-testnet" | ||||
| @ -1302,6 +1342,13 @@ if [ "${BITCOIN_SIGNET_ENABLE}" = ON ];then | ||||
|     echo "[*] Installing Bitcoin Signet electrs start script" | ||||
|     osSudo "${ROOT_USER}" install -c -o "${BITCOIN_USER}" -g "${BITCOIN_GROUP}" -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/electrs-start-signet" "${BITCOIN_ELECTRS_HOME}" | ||||
| 
 | ||||
|     case $OS in | ||||
|         Debian) | ||||
|             echo "[*] Installing Bitcoin-signet crontab" | ||||
|             (crontab -l ; echo "@reboot sleep 90 ; screen -dmS signet /bitcoin/electrs/electrs-start-signet") | osSudo "${ROOT_USER}" crontab -u "${BITCOIN_USER}" - | ||||
|         ;; | ||||
|     esac | ||||
| 
 | ||||
|     echo "[*] Configuring Bitcoin Signet RPC credentials in electrs start script" | ||||
|     osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${BITCOIN_ELECTRS_HOME}/electrs-start-signet" | ||||
|     osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${BITCOIN_ELECTRS_HOME}/electrs-start-signet" | ||||
| @ -1317,8 +1364,15 @@ if [ "${ELEMENTS_LIQUID_ENABLE}" = ON ];then | ||||
|     osSudo "${ROOT_USER}" install -c -o "${ELEMENTS_USER}" -g "${ELEMENTS_GROUP}" -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/electrs-start-liquid" "${ELEMENTS_ELECTRS_HOME}" | ||||
| 
 | ||||
|     echo "[*] Installing Elements crontab" | ||||
|     # FIXME: must only crontab enabled daemons | ||||
|     osSudo "${ROOT_USER}" crontab -u "${ELEMENTS_USER}" "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/elements.crontab" | ||||
|     case $OS in | ||||
|         FreeBSD) | ||||
|             echo [*] FIXME: must only crontab enabled daemons | ||||
|             osSudo "${ROOT_USER}" crontab -u "${ELEMENTS_USER}" "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/elements.crontab" | ||||
|         ;; | ||||
|         Debian) | ||||
|             (crontab -l ; echo "6 * * * * cd $HOME/asset_registry_db && git pull origin master >/dev/null 2>&1") | osSudo "${ROOT_USER}" crontab -u "${ELEMENTS_USER}" - | ||||
|         ;; | ||||
|     esac | ||||
| 
 | ||||
|     echo "[*] Configuring Elements Liquid RPC credentials in electrs start script" | ||||
|     osSudo "${ROOT_USER}" sed -i.orig "s/__ELEMENTS_RPC_USER__/${ELEMENTS_RPC_USER}/" "${ELEMENTS_ELECTRS_HOME}/electrs-start-liquid" | ||||
| @ -1334,6 +1388,13 @@ if [ "${ELEMENTS_LIQUIDTESTNET_ENABLE}" = ON ];then | ||||
|     echo "[*] Installing Elements Liquid Testnet electrs start script" | ||||
|     osSudo "${ROOT_USER}" install -c -o "${ELEMENTS_USER}" -g "${ELEMENTS_GROUP}" -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/electrs-start-liquidtestnet" "${ELEMENTS_ELECTRS_HOME}" | ||||
| 
 | ||||
|     case $OS in | ||||
|         Debian) | ||||
|             echo "[*] Installing Elements-testnet crontab" | ||||
|             (crontab -l ; echo "6 * * * * cd $HOME/asset_registry_testnet_db && git pull origin master >/dev/null 2>&1") | osSudo "${ROOT_USER}" crontab -u "${ELEMENTS_USER}" - | ||||
|         ;; | ||||
|     esac | ||||
| 
 | ||||
|     echo "[*] Installing Elements Liquid Testnet RPC credentials" | ||||
|     osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_USER__/${BITCOIN_RPC_USER}/" "${ELEMENTS_HOME}/elements.conf" | ||||
|     osSudo "${ROOT_USER}" sed -i.orig "s/__BITCOIN_RPC_PASS__/${BITCOIN_RPC_PASS}/" "${ELEMENTS_HOME}/elements.conf" | ||||
| @ -1473,23 +1534,21 @@ case $OS in | ||||
|         fi | ||||
|         if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then | ||||
|             osSudo "${ROOT_USER}" systemctl enable bitcoin.service | ||||
|             osSudo "${ROOT_USER}" systemctl enable mempool.service | ||||
|         fi | ||||
|         if [ "${BITCOIN_MAINNET_MINFEE_ENABLE}" = ON ];then | ||||
|             osSudo "${ROOT_USER}" systemctl enable bitcoin-minfee.service | ||||
|         fi | ||||
|         if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then | ||||
|             osSudo "${ROOT_USER}" systemctl enable bitcoin-testnet.service | ||||
|             osSudo "${ROOT_USER}" systemctl enable mempool-testnet.service | ||||
|         fi | ||||
|         if [ "${BITCOIN_SIGNET_ENABLE}" = ON ];then | ||||
|             osSudo "${ROOT_USER}" systemctl enable bitcoin-signet.service | ||||
|             osSudo "${ROOT_USER}" systemctl enable mempool-signet.service | ||||
|         fi | ||||
|         if [ "${BISQ_MAINNET_ENABLE}" = ON ];then | ||||
|             osSudo "${ROOT_USER}" systemctl enable bisq.service | ||||
|             osSudo "${ROOT_USER}" systemctl enable mempool-bisq.service | ||||
|         fi | ||||
|         if [ "${ELEMENTS_LIQUID_ENABLE}" = ON ];then | ||||
|             osSudo "${ROOT_USER}" systemctl enable liquid.service | ||||
|             osSudo "${ROOT_USER}" systemctl enable mempool-liquid.service | ||||
|         fi | ||||
|     ;; | ||||
| esac | ||||
|  | ||||
							
								
								
									
										22
									
								
								production/linux/bitcoin-minfee.service
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								production/linux/bitcoin-minfee.service
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| [Unit] | ||||
| Description=Bitcoind-minfee | ||||
| After=network.target | ||||
| 
 | ||||
| [Service] | ||||
| ExecStart=/usr/local/bin/bitcoind -daemon -printtoconsole -pid=/minfee/bitcoind-minfee.pid | ||||
| ExecStop=/usr/local/bin/bitcoin-cli stop | ||||
| 
 | ||||
| Type=forking | ||||
| PIDFile=/minfee/bitcoind.pid | ||||
| Restart=on-failure | ||||
| 
 | ||||
| User=minfee | ||||
| Group=minfee | ||||
| 
 | ||||
| PrivateTmp=true | ||||
| ProtectSystem=full | ||||
| NoNewPrivileges=true | ||||
| PrivateDevices=true | ||||
| 
 | ||||
| [Install] | ||||
| WantedBy=multi-user.target | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user