├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── LICENSE ├── README.md ├── config ├── monero-bash.conf ├── monero-wallet-cli.conf ├── monerod.conf ├── p2pool.conf └── xmrig.json ├── docs ├── README.md ├── fake_http_headers │ ├── accept │ ├── language │ ├── referer │ ├── sec_fetch_dest │ ├── sec_fetch_mode │ ├── sec_fetch_site │ ├── tor_browser │ ├── user_agent │ └── wget_curl ├── seed │ ├── dutch │ ├── english │ ├── esperanto │ ├── french │ ├── german │ ├── italian │ ├── japanese │ ├── lojban │ ├── portuguese │ ├── russian │ └── spanish └── upgrade_explanation.md ├── external └── README.md ├── gpg ├── SChernykh.asc ├── binaryfate.asc ├── hinto-janai.asc ├── hinto-janaiyo.asc └── xmrig.asc ├── monero-bash ├── src ├── README.md ├── api │ └── mini ├── debug.sh ├── func │ ├── backup.sh │ ├── build.sh │ ├── code.sh │ ├── compromised.sh │ ├── define.sh │ ├── download.sh │ ├── edit.sh │ ├── eol.sh │ ├── error.sh │ ├── gpg.sh │ ├── header.sh │ ├── install.sh │ ├── libconfig.sh │ ├── libjson.sh │ ├── log.sh │ ├── mine.sh │ ├── missing.sh │ ├── monerobash.sh │ ├── panic.sh │ ├── parse.sh │ ├── path.sh │ ├── permission.sh │ ├── price.sh │ ├── print.sh │ ├── process.sh │ ├── prompt.sh │ ├── remove.sh │ ├── reset.sh │ ├── rpc.sh │ ├── safety.sh │ ├── seed.sh │ ├── status.sh │ ├── systemd.sh │ ├── tmp.sh │ ├── torsocks.sh │ ├── trap.sh │ ├── update.sh │ ├── upgrade.sh │ ├── verbose.sh │ ├── verify.sh │ ├── version.sh │ ├── wallet.sh │ ├── warning.sh │ └── watch.sh ├── libtorsocks.so ├── source.sh ├── txt │ ├── hashlist │ ├── state │ └── usage └── var.sh ├── systemd ├── README.md ├── monero-bash-monerod.service ├── monero-bash-p2pool.service └── monero-bash-xmrig.service ├── tests ├── install_all └── install_all_HTML └── utils ├── aliases ├── hash ├── prepare ├── release ├── tmp_install └── upgrade /.gitignore: -------------------------------------------------------------------------------- 1 | .old/ 2 | *.swp 3 | *.save 4 | #external 5 | lib 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/xmrpc"] 2 | path = external/xmrpc 3 | url = https://github.com/jtgrassie/xmrpc 4 | [submodule "external/torsocks"] 5 | path = external/torsocks 6 | url = https://github.com/dgoulet/torsocks 7 | [submodule "external/JSON.sh"] 8 | path = external/JSON.sh 9 | url = https://github.com/dominictarr/JSON.sh 10 | [submodule "external/libconfig"] 11 | path = external/libconfig 12 | url = https://github.com/hinto-janaiyo/libconfig 13 | [submodule "external/libjson"] 14 | path = external/libjson 15 | url = https://github.com/hinto-janaiyo/libjson 16 | [submodule "external/stdlib"] 17 | path = external/stdlib 18 | url = https://github.com/hinto-janaiyo/stdlib 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 hinto.janaiyo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /config/monero-bash.conf: -------------------------------------------------------------------------------- 1 | ##===========================## 2 | ## monero-bash configuration ## 3 | ##=====================================================## 4 | ## Below is the configuration for: ## 5 | ## [monero-bash] and other misc features. ## 6 | ## ## 7 | ## More advanced settings are commented out with a '#' ## 8 | ## To use these, uncomment them (delete the #) ## 9 | ## ## 10 | ## '##' = explaination & usage ## 11 | ## '#' = disabled/commented option ## 12 | ##=====================================================## 13 | 14 | 15 | ##---------------------------------------------------------------------------## 16 | ## monero-bash ## 17 | ##---------------------------------------------------------------------------## 18 | ## Auto-start [monerod] in the background when opening a wallet. 19 | ## Warning: Timing correlation attacks are much easier if you ONLY sync when 20 | ## using your wallet. You may want to leave `monerod` running at all times. 21 | ## USAGE: [true|false] 22 | AUTO_START_DAEMON=false 23 | 24 | ## Auto-stop [monerod] in the background after closing a wallet 25 | ## USAGE: [true|false] 26 | AUTO_STOP_DAEMON=false 27 | 28 | ## Auto-update packages when you run [monero-bash] 29 | ## USAGE: [true|false] 30 | AUTO_UPDATE=false 31 | 32 | ## Warn about IP exposure when using [monero-bash price] 33 | ## USAGE: [true|false] 34 | PRICE_API_IP_WARNING=true 35 | 36 | ## The interval of seconds to refresh when using [monero-bash watch] 37 | ## Default is [5] seconds, less might be too fast for slow computers 38 | ## USAGE: [1-60] 39 | WATCH_REFRESH_RATE=5 40 | 41 | ##---------------------------------------------------------------------------## 42 | ## Tor ## 43 | ##---------------------------------------------------------------------------## 44 | ## Enable [monero-bash] to use TOR. Connections will be passed to [monero-bash]'s 45 | ## built-in version of 'torsocks', so downloading it seperately is not required. 46 | ## TOR is obviously required. The affected connections are the Package Manager, 47 | ## [monero-bash rpc] calls (that aren't localhost) and [monero-bash price]. 48 | ## THIS SETTING ONLY AFFECTS [MONERO-BASH], NOT [MONERO/P2POOL/XMRIG]! 49 | ## USAGE: [true|false] 50 | #USE_TOR=true 51 | 52 | ## Enabling this makes [monero-bash] check [https://check.torproject.org] 53 | ## and run a couple of other tests to see if Tor is working before attempting 54 | ## to create any new connections. A message will appear if it succeeds/fails. 55 | ## Turned off by default. 56 | ## USAGE: [true|false] 57 | #TEST_TOR=true 58 | 59 | ## The TOR SOCKS proxy IP:PORT to use, default is [127.0.0.1:9050] 60 | ## USAGE: [IP:PORT] 61 | #TOR_PROXY=127.0.0.1:9050 62 | 63 | ## Silences the Tor set-up messages (tests will still be run) 64 | ## USAGE: [true|false] 65 | #TOR_QUIET=true 66 | 67 | ##----------------------------------------------------------------------------## 68 | ## HTTP Headers ## 69 | ##----------------------------------------------------------------------------## 70 | ## Send fake HTTP headers when downloading. Including but not limited to: 71 | ## [User agent, ACCEPT values, referer, etc]. This is useful to blend in 72 | ## as a regular web browser when downloading packages. 73 | ## USAGE: [true|false] 74 | #FAKE_HTTP_HEADERS=true 75 | 76 | ## Make your HTTP headers mimic the [Tor browser] instead of randomly picking common 77 | ## values. This will override the [ONLY_USER_AGENT] & [ONLY_WGET_CURL] settings below, 78 | ## unless sending a non-local RPC call, that will always use a Wget/Curl user-agent. 79 | ## USAGE: [true|false] 80 | #TOR_BROWSER_MIMIC=true 81 | 82 | ## Only send the [User-Agent] HTTP header. 83 | ## USAGE: [true|false] 84 | #ONLY_USER_AGENT=true 85 | 86 | ## Rather than browser-like User-Agents, use randomly selected [2016-2022] 87 | ## versions of Wget/Curl. This and [ONLY_USER_AGENT] are always enabled when 88 | ## sending a non-local Monero RPC call with [monero-bash rpc]. 89 | ## USAGE: [true|false] 90 | #ONLY_WGET_CURL=true 91 | 92 | ## Print the fake headers that will be used before creating any connections. 93 | ## USAGE: [true|false] 94 | #HTTP_HEADERS_VERBOSE=true 95 | 96 | ##----------------------------------------------------------------------------## 97 | ## Monero RPC ## 98 | ##----------------------------------------------------------------------------## 99 | ## The [monerod] IP to use when sending an RPC call with [monero-bash rpc] 100 | ## This IP will also be used to get stats when using [monero-bash status] 101 | ## It can be any node, the default is [127.0.0.1] (your local node) 102 | ## This (can be) a completely different RPC IP from the one used by P2Pool. 103 | ## USAGE: [MONERO_NODE_IP:PORT] 104 | DAEMON_RPC_IP=127.0.0.1:18081 105 | 106 | ## Print the [monerod] IP and JSON payload alongside the RPC call. 107 | ## USAGE: [true|false] 108 | #DAEMON_RPC_VERBOSE= 109 | 110 | ##---------------------------------------------------------------------------## 111 | ## Hugepages ## 112 | ##---------------------------------------------------------------------------## 113 | ## Auto-setup hugepages when using [monero-bash start all] 114 | ## This allows for smoother operation when running all processes. 115 | ## USAGE: [true|false] 116 | #AUTO_HUGEPAGES= 117 | 118 | ## How many MB of hugepages? Default is [3072] (1024 per process) 119 | ## USAGE: [MEGABYTES] 120 | #HUGEPAGES=3072 121 | -------------------------------------------------------------------------------- /config/monero-wallet-cli.conf: -------------------------------------------------------------------------------- 1 | ##=================================## 2 | ## monero-wallet-cli configuration ## 3 | ##================================================================## 4 | ## Below is a decent amount of configuration ## 5 | ## options for your 'monero-wallet-cli'. ## 6 | ## It is already set with sane defaults so you ## 7 | ## shouldn't need to touch anything. ## 8 | ## ## 9 | ## More advanced settings are commented out with a '#' ## 10 | ## To use these, uncomment them (delete the #) ## 11 | ## ## 12 | ## '##' = explaination & usage ## 13 | ## '#' = disabled/commented option ## 14 | ## ## 15 | ## Complete 'monero-wallet-cli' configuration docs here: ## 16 | ## https://monerodocs.org/interacting/monero-wallet-cli-reference ## 17 | ##================================================================## 18 | 19 | 20 | ##------------------------------------------------------## 21 | ## MONEROD CONNECTION ## 22 | ##------------------------------------------------------## 23 | ## The 'monerod' to connect to. Default is '127.0.0.1:18081' 24 | ## which is your own Monero node. 25 | ## USAGE: [IP:PORT] 26 | daemon-address=127.0.0.1:18081 27 | 28 | ## Specify username[:password] for monerod RPC API. It is based on HTTP Basic Auth. 29 | ## Mind that connections are by default unencrypted. Authentication only makes sense 30 | ## if you establish a secure connection (maybe via Tor, or SSH tunneling, or reverse proxy w/ TLS). 31 | ## EXAMPLE: my_username:my_password 32 | ## USAGE: [ username[:password] ] 33 | #daemon-login= 34 | 35 | ## Enable commands and behaviors which rely on 'monerod' 36 | ## instance being trusted. Default is [true] for localhost connections. 37 | ## The trust in this context concerns preserving your privacy. 38 | ## Only use this flag if you do control monerod. 39 | ## USAGE: [true|false] 40 | #trusted-daemon= 41 | 42 | ## Disable commands and behaviors which rely on 'monerod' 43 | ## instance being trusted. Default is [true] for non-localhost connections. 44 | ## USAGE: [true|false] 45 | #untrusted-daemon= 46 | 47 | ## Allow communicating with monerod that uses a different RPC version. 48 | ## USAGE: [true|false] 49 | #allow-mismatched-daemon-version= 50 | 51 | ##-----------------------------------------------------## 52 | ## TOR/I2P ## 53 | ##-----------------------------------------------------## 54 | ## The usage of these networks is still considered experimental. 55 | ## Full usage here: https://github.com/monero-project/monero/blob/master/docs/ANONYMITY_NETWORKS.md 56 | 57 | ## Configure the wallet to use a Tor/i2p proxy. 58 | ## USAGE: [TOR_IP:TOR_PORT] 59 | #proxy 127.0.0.1:9050 60 | 61 | ## Configure the wallet to use a Tor/i2p address. 62 | ## USAGE: [IP_ADDRESS.] 63 | #daemon-address=ADDRESS.onion 64 | 65 | ##------------------------------------------------------## 66 | ## LOG ## 67 | ##------------------------------------------------------## 68 | ## 0 is minimal logging and 4 is full tracing. Defaults to 0. 69 | ## These are general presets and do not directly map to severity levels. 70 | ## For example, even with minimal 0, you may see some most important INFO entries. 71 | ## USAGE: [0-4] 72 | log-level=0 73 | 74 | ##------------------------------------------------------## 75 | ## TRANSACTIONS ## 76 | ##------------------------------------------------------## 77 | ## Newly created transaction will not be relayed to the Monero network. 78 | ## Instead it will be dumped to a file in a raw hexadecimal format. 79 | ## Useful if you want to push the transaction through a gateway like https://xmrchain.net/rawtx 80 | ## or for offline signing. This may be easier to use over Tor than Monero wallet. 81 | ## USAGE: [true|false] 82 | #do-not-relay= 83 | 84 | ##--------------------------------------------------------## 85 | ## PERFORMANCE ## 86 | ##--------------------------------------------------------## 87 | ## Max number of threads to use for parallel jobs. 88 | ## The default value 0 uses the number of CPU threads. 89 | ## USAGE: [CPU_THREAD_INTEGER] 90 | #max-concurrency= 91 | -------------------------------------------------------------------------------- /config/p2pool.conf: -------------------------------------------------------------------------------- 1 | ##======================## 2 | ## P2Pool configuration ## 3 | ##==============================================================## 4 | ## This configuration file affects P2Pool when running it with: ## 5 | ## [monero-bash full p2pool] OR [monero-bash start p2pool] ## 6 | ## ## 7 | ## '##' = explaination & usage ## 8 | ## '#' = disabled/commented option ## 9 | ##==============================================================## 10 | 11 | ## Address to send P2Pool payouts to. Subaddresses/integrated addresses are not supported! 12 | ## Remember, P2Pool wallets are public! It's recommended to create a seperate mining wallet. 13 | ## USAGE: [MONERO_WALLET_STARTING_WITH_4] 14 | WALLET= 15 | 16 | ## Use the P2Pool mini side-chain? Default is [false] 17 | ## USAGE: [true|false] 18 | MINI=false 19 | 20 | ## IP address of the Monero node to use, default is [127.0.0.1] (your local node) 21 | ## USAGE: [MONERO_NODE_IP] 22 | DAEMON_IP=127.0.0.1 23 | 24 | ## RPC port of the Monero node to use, default is [18081] 25 | ## USAGE: [MONERO_NODE_RPC_PORT] 26 | DAEMON_RPC=18081 27 | 28 | ## ZMQ port of the Monero node to use, default is [18083] 29 | ## USAGE: [MONERO_NODE_ZMQ_PORT] 30 | DAEMON_ZMQ=18083 31 | 32 | ## Maximum number of outgoing P2P connections, default is [10] 33 | ## USAGE: [10-450] 34 | OUT_PEERS=10 35 | 36 | ## Maximum number of incoming P2P connections, default is [10] 37 | ## USAGE: [10-450] 38 | IN_PEERS=10 39 | 40 | ## Verbosity of the P2Pool log/output, default is [3] 41 | ## If this is set to [0], your P2Pool stats when running 42 | ## 'monero-bash status' might be _slightly_ inaccurate. 43 | ## USAGE: [0-6] 44 | LOG_LEVEL=3 45 | -------------------------------------------------------------------------------- /config/xmrig.json: -------------------------------------------------------------------------------- 1 | // [XMRig configuration] 2 | // --------------------- 3 | // This file configures XMRig when used with [monero-bash]. 4 | // To configure basic settings, use: [monero-bash config]. 5 | // To use the official config wizard: https://config.xmrig.com 6 | // ^ 7 | // |__ Make sure to replace this file with the new one if you use this! 8 | // 9 | // This file is already pre-configured with options that most people would want. 10 | // You can replace: [url: 127.0.0.1:3333] with your pool IP (default is set to your local P2Pool) 11 | // And replace: [user: YOUR_WALLET_ADDRESS] with your address. If you're using P2Pool, you set 12 | // the wallet address in P2Pool, not here. Edit [monero-bash.conf] to configure P2Pool. 13 | { 14 | "api": { 15 | "id": null, 16 | "worker-id": null 17 | }, 18 | "http": { 19 | "enabled": false, 20 | "host": "127.0.0.1", 21 | "port": 0, 22 | "access-token": null, 23 | "restricted": true 24 | }, 25 | "autosave": true, 26 | "background": false, 27 | "colors": true, 28 | "title": true, 29 | "randomx": { 30 | "init": -1, 31 | "init-avx2": -1, 32 | "mode": "auto", 33 | "1gb-pages": true, 34 | "rdmsr": true, 35 | "wrmsr": true, 36 | "cache_qos": false, 37 | "numa": true, 38 | "scratchpad_prefetch_mode": 1 39 | }, 40 | "cpu": { 41 | "enabled": true, 42 | "huge-pages": true, 43 | "huge-pages-jit": true, 44 | "hw-aes": null, 45 | "priority": null, 46 | "memory-pool": false, 47 | "yield": true, 48 | "max-threads-hint": 100, 49 | "asm": true, 50 | "argon2-impl": null, 51 | "astrobwt-max-size": 550, 52 | "astrobwt-avx2": false, 53 | "cn/0": false, 54 | "cn-lite/0": false 55 | }, 56 | "opencl": { 57 | "enabled": false, 58 | "cache": true, 59 | "loader": null, 60 | "platform": "AMD", 61 | "adl": true, 62 | "cn/0": false, 63 | "cn-lite/0": false 64 | }, 65 | "cuda": { 66 | "enabled": false, 67 | "loader": null, 68 | "nvml": true, 69 | "cn/0": false, 70 | "cn-lite/0": false 71 | }, 72 | "donate-level": 1, 73 | "donate-over-proxy": 1, 74 | "log-file": null, 75 | "pools": [ 76 | { 77 | "algo": "rx/0", 78 | "coin": "Monero", 79 | "url": "127.0.0.1:3333", 80 | "user": "YOUR_WALLET_ADDRESS", 81 | "pass": "x", 82 | "rig-id": null, 83 | "nicehash": false, 84 | "keepalive": false, 85 | "enabled": true, 86 | "tls": false, 87 | "tls-fingerprint": null, 88 | "daemon": false, 89 | "socks5": null, 90 | "self-select": null, 91 | "submit-to-origin": false 92 | } 93 | ], 94 | "print-time": 60, 95 | "health-print-time": 60, 96 | "dmi": true, 97 | "retries": 5, 98 | "retry-pause": 5, 99 | "syslog": false, 100 | "tls": { 101 | "enabled": false, 102 | "protocols": null, 103 | "cert": null, 104 | "cert_key": null, 105 | "ciphers": null, 106 | "ciphersuites": null, 107 | "dhparam": null 108 | }, 109 | "dns": { 110 | "ipv6": false, 111 | "ttl": 30 112 | }, 113 | "user-agent": null, 114 | "verbose": 0, 115 | "watch": true, 116 | "pause-on-battery": false, 117 | "pause-on-active": false 118 | } 119 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ## [monero-bash] docs 2 | 3 | This folder contains some misc files: 4 | * [monero-bash upgrade explaination](https://github.com/hinto-janai/monero-bash/blob/main/docs/upgrade_explanation.md) 5 | * [Fake HTTP header data](https://github.com/hinto-janai/monero-bash/tree/main/docs/fake_http_headers) 6 | * [Monero seed list for all languages, in raw text and in Bash array format](https://github.com/hinto-janai/monero-bash/tree/main/docs/seed) 7 | -------------------------------------------------------------------------------- /docs/fake_http_headers/referer: -------------------------------------------------------------------------------- 1 | https://www.google.com 2 | https://www.duckduckgo.com 3 | https://www.startpage.com 4 | https://www.reddit.com 5 | https://www.twitter.com 6 | https://youtube.com 7 | https://yandex.ru 8 | https://out.reddit.com 9 | https://github.com 10 | https://facebook.com 11 | 12 | ARRAY[0]='https://www.google.com' 13 | ARRAY[1]='https://www.duckduckgo.com' 14 | ARRAY[2]='https://www.startpage.com' 15 | ARRAY[3]='https://www.reddit.com' 16 | ARRAY[4]='https://www.twitter.com' 17 | ARRAY[5]='https://youtube.com' 18 | ARRAY[6]='https://yandex.ru' 19 | ARRAY[7]='https://out.reddit.com' 20 | ARRAY[8]='https://github.com' 21 | ARRAY[9]='https://facebook.com' 22 | -------------------------------------------------------------------------------- /docs/fake_http_headers/sec_fetch_dest: -------------------------------------------------------------------------------- 1 | document 2 | embed 3 | object 4 | 5 | SEC_FETCH_DEST[0]='document' 6 | SEC_FETCH_DEST[1]='embed' 7 | SEC_FETCH_DEST[2]='object' 8 | -------------------------------------------------------------------------------- /docs/fake_http_headers/sec_fetch_mode: -------------------------------------------------------------------------------- 1 | cors 2 | navigate 3 | same-origin 4 | websocket 5 | 6 | SEC_FETCH_MODE[0]='cors' 7 | SEC_FETCH_MODE[1]='navigate' 8 | SEC_FETCH_MODE[2]='same-origin' 9 | SEC_FETCH_MODE[3]='websocket' 10 | -------------------------------------------------------------------------------- /docs/fake_http_headers/sec_fetch_site: -------------------------------------------------------------------------------- 1 | cross-site 2 | same-origin 3 | same-site 4 | none 5 | 6 | SEC_FETCH_SITE[0]='cross-site' 7 | SEC_FETCH_SITE[1]='same-origin' 8 | SEC_FETCH_SITE[2]='same-site' 9 | SEC_FETCH_SITE[3]='none' 10 | -------------------------------------------------------------------------------- /docs/fake_http_headers/tor_browser: -------------------------------------------------------------------------------- 1 | # These are the values used by [Tor browser] as of 2022 September 7. 2 | # Some of the values (Cache, Sec, etc) are randomly selected while 3 | # some values (Accept, Encoding, User-Agent) are constants. 4 | 5 | Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 6 | Accept-Encoding: gzip, deflate, br 7 | Accept-Language: en-US,en;q=0.5 8 | Cache-Control: max-age=0 9 | Connection: keep-alive 10 | Sec-Fetch-Dest: document 11 | Sec-Fetch-Mode: navigate 12 | Sec-Fetch-Site: none 13 | Sec-Fetch-User: ?1 14 | Upgrade-Insecure-Requests: 1 15 | User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Firefox/102.0 16 | -------------------------------------------------------------------------------- /docs/fake_http_headers/wget_curl: -------------------------------------------------------------------------------- 1 | Wget/1.15 2 | Wget/1.16 3 | Wget/1.16.1 4 | Wget/1.16.2 5 | Wget/1.16.3 6 | Wget/1.17 7 | Wget/1.17.1 8 | Wget/1.18 9 | Wget/1.18 10 | Wget/1.19 11 | Wget/1.19.1 12 | Wget/1.19.2 13 | Wget/1.19.3 14 | Wget/1.19.4 15 | Wget/1.19.5 16 | Wget/1.20 17 | Wget/1.20.1 18 | Wget/1.20.2 19 | Wget/1.20.3 20 | Wget/1.21 21 | Wget/1.21.1 22 | Wget/1.21.2 23 | Wget/1.21.3 24 | curl/7.62.0 25 | curl/7.63.0 26 | curl/7.64.0 27 | curl/7.64.1 28 | curl/7.65.0 29 | curl/7.65.1 30 | curl/7.65.2 31 | curl/7.65.3 32 | curl/7.66.0 33 | curl/7.67.0 34 | curl/7.68.0 35 | curl/7.69.0 36 | curl/7.69.1 37 | curl/7.70.0 38 | curl/7.70.1 39 | curl/7.71.0 40 | curl/7.71.1 41 | curl/7.72.0 42 | curl/7.73.0 43 | curl/7.74.0 44 | curl/7.75.0 45 | curl/7.76.0 46 | curl/7.76.1 47 | curl/7.77.0 48 | curl/7.78.0 49 | curl/7.79.0 50 | curl/7.79.1 51 | curl/7.80.0 52 | curl/7.81.0 53 | curl/7.82.0 54 | curl/7.83.0 55 | curl/7.83.1 56 | curl/7.84.0 57 | curl/7.85.0 58 | curl/7.86.0 59 | curl/7.87.1 60 | curl/7.88.0 61 | curl/7.88.1 62 | 63 | ARRAY[0]='Wget/1.15' 64 | ARRAY[1]='Wget/1.16' 65 | ARRAY[2]='Wget/1.16.1' 66 | ARRAY[3]='Wget/1.16.2' 67 | ARRAY[4]='Wget/1.16.3' 68 | ARRAY[5]='Wget/1.17' 69 | ARRAY[6]='Wget/1.17.1' 70 | ARRAY[7]='Wget/1.18' 71 | ARRAY[8]='Wget/1.18' 72 | ARRAY[9]='Wget/1.19' 73 | ARRAY[10]='Wget/1.19.1' 74 | ARRAY[11]='Wget/1.19.2' 75 | ARRAY[12]='Wget/1.19.3' 76 | ARRAY[13]='Wget/1.19.4' 77 | ARRAY[14]='Wget/1.19.5' 78 | ARRAY[15]='Wget/1.20' 79 | ARRAY[16]='Wget/1.20.1' 80 | ARRAY[17]='Wget/1.20.2' 81 | ARRAY[18]='Wget/1.20.3' 82 | ARRAY[19]='Wget/1.21' 83 | ARRAY[20]='Wget/1.21.1' 84 | ARRAY[21]='Wget/1.21.2' 85 | ARRAY[22]='Wget/1.21.3' 86 | ARRAY[23]='curl/7.62.0' 87 | ARRAY[24]='curl/7.63.0' 88 | ARRAY[25]='curl/7.64.0' 89 | ARRAY[26]='curl/7.64.1' 90 | ARRAY[27]='curl/7.65.0' 91 | ARRAY[28]='curl/7.65.1' 92 | ARRAY[29]='curl/7.65.2' 93 | ARRAY[30]='curl/7.65.3' 94 | ARRAY[31]='curl/7.66.0' 95 | ARRAY[32]='curl/7.67.0' 96 | ARRAY[33]='curl/7.68.0' 97 | ARRAY[34]='curl/7.69.0' 98 | ARRAY[35]='curl/7.69.1' 99 | ARRAY[36]='curl/7.70.0' 100 | ARRAY[37]='curl/7.70.1' 101 | ARRAY[38]='curl/7.71.0' 102 | ARRAY[39]='curl/7.71.1' 103 | ARRAY[40]='curl/7.72.0' 104 | ARRAY[41]='curl/7.73.0' 105 | ARRAY[42]='curl/7.74.0' 106 | ARRAY[43]='curl/7.75.0' 107 | ARRAY[44]='curl/7.76.0' 108 | ARRAY[45]='curl/7.76.1' 109 | ARRAY[46]='curl/7.77.0' 110 | ARRAY[47]='curl/7.78.0' 111 | ARRAY[48]='curl/7.79.0' 112 | ARRAY[49]='curl/7.79.1' 113 | ARRAY[50]='curl/7.80.0' 114 | ARRAY[51]='curl/7.81.0' 115 | ARRAY[52]='curl/7.82.0' 116 | ARRAY[53]='curl/7.83.0' 117 | ARRAY[54]='curl/7.83.1' 118 | ARRAY[55]='curl/7.84.0' 119 | ARRAY[56]='curl/7.85.0' 120 | ARRAY[57]='curl/7.86.0' 121 | ARRAY[58]='curl/7.87.1' 122 | ARRAY[59]='curl/7.88.0' 123 | ARRAY[60]='curl/7.88.1' 124 | -------------------------------------------------------------------------------- /docs/upgrade_explanation.md: -------------------------------------------------------------------------------- 1 | # How does monero-bash upgrade packages? 2 | * [Intro](#Intro) 3 | * [Download](#Download) 4 | * [Verify](#Verify) 5 | * [Upgrade](#Upgrade) 6 | * [Details](#Details) 7 | * Date: 2022-04-07 8 | 9 | ## Intro 10 | The monero-bash upgrade process is: 11 | * Download 12 | * Verify 13 | * Upgrade 14 | 15 | Here's a very simplified step-by-step explanation of what happens when you `monero-bash upgrade` 16 | 17 | ## Download 18 | ``` 19 | download_Monero() { 20 | wget -P "$tmp" -q --show-progress --content-disposition "https://downloads.getmonero.org/cli/linux64" 21 | } 22 | ``` 23 | For this example, let's download `Monero` 24 | 25 | The download function does a simple job: 26 | 1. It downloads `https://downloads.getmonero.org/cli/linux64` into a temporary folder with a progress bar 27 | 28 | ## Verify 29 | ``` 30 | verify_hash_Monero() { 31 | echo "$HASH" "$tar" | sha256sum -c 32 | } 33 | ``` 34 | After successful download, `monero-bash`: 35 | 1. Checks if the tar hash matches `https://www.getmonero.org/downloads/hashes.txt` 36 | 2. Either prints a green `OK` or a red `FAILED` message 37 | 38 | ## Upgrade 39 | ``` 40 | upgrade_Monero() { 41 | if [[ $verifyOK = "true" ]]; then 42 | tar -xf "$tar" 43 | mv "$folderName" "$currentFolder" 44 | sudo sed -i "s@.*"$NAME_CAPS"_VER=.*@"$NAME_CAPS"_VER=\""$NewVer"\"@" "$state" 45 | else 46 | compromised_Monero_Hash 47 | exit 48 | fi 49 | } 50 | ``` 51 | If the verification goes well, `monero-bash`: 52 | 1. Extracts the `tar` file 53 | 2. Replaces the old `Monero` folder with the new 54 | 3. Edits the local `state` file with new info 55 | 56 | If the verification **fails,** `monero-bash`: 57 | 1. Spits out a [scary looking message](https://github.com/hinto-janai/monero-bash/blob/main/src/func/compromised.sh) 58 | 2. Exits immediately 59 | 60 | Since monero-bash gets installed in `/usr/local/share/monero-bash/`, sudo is required to edit the `state` file when upgrading/installing 61 | 62 | ## Details 63 | For the sake of being simple and easy to read, the functions presented in the examples above were ***heavily*** reduced. 64 | 65 | [I encourage you to click here to see the actual upgrade function](https://github.com/hinto-janai/monero-bash/blob/main/src/func/upgrade.sh) 66 | 67 | And here for some of the important functions it's made out of: [Define](https://github.com/hinto-janai/monero-bash/blob/main/src/func/define.sh) - [Download](https://github.com/hinto-janai/monero-bash/blob/main/src/func/download.sh) - [Verify](https://github.com/hinto-janai/monero-bash/blob/main/src/func/verify.sh) - [Version](https://github.com/hinto-janai/monero-bash/blob/main/src/func/version.sh) 68 | 69 | What you'll find is a bunch of grep/awk/sed, error handling, cleanup, and safety checks. 70 | 71 | As for PGP keys, here is the full import function: 72 | ``` 73 | gpg_import_Template() { 74 | local LOCAL="$(cat "$installDirectory/gpg/${GPG_OWNER}.asc")" 75 | local ONLINE="$(wget -qO- "$GPG_PUB_KEY")" 76 | 77 | if [[ "$LOCAL" = "$ONLINE" ]]; then 78 | echo -n "$GPG_OWNER: " 79 | echo "OK" ;$off 80 | gpg --import "$installDirectory/gpg/${GPG_OWNER}.asc" 81 | echo 82 | else 83 | gpg_Diff 84 | fi 85 | } 86 | ``` 87 | Before any key is imported, it's checked against the official version found ONLINE. If the key monero-bash comes with DOES NOT match the key found online, you will be prompted for a decision on what to do. 88 | 89 | [To see all GPG-related functions, click here](https://github.com/hinto-janai/monero-bash/blob/main/src/func/gpg.sh) 90 | -------------------------------------------------------------------------------- /external/README.md: -------------------------------------------------------------------------------- 1 | # external 2 | 3 | These are external projects that monero-bash relies on for certain features. 4 | 5 | | Name | Purpose | Original creator/contributors | 6 | |-----------------------------------------------------------|---------------------------------|---------------------------------| 7 | | [`JSON.sh`](https://github.com/dominictarr/JSON.sh) | JSON parser | Dominic Tarr 8 | | [`torsocks`](https://github.com/dgoulet/torsocks) | Tor wrapper | The Tor Project, Tamas Szerb, Robert Hogan, David Goulet, Alex Xu 9 | | [`xmrpc`](https://github.com/jtgrassie/xmrpc) | Monero RPC parser/executor | jtgrassie 10 | | [`libjson`](https://github.com/hinto-janai/libjson) | JSON -> Bash variable converter | hinto-janai 11 | | [`libconfig`](https://github.com/hinto-janai/libconfig) | Safe config parser | hinto-janai 12 | | [`stdlib`](https://github.com/hinto-janai/stdlib) | General purpose Bash functions | hinto-janai 13 | -------------------------------------------------------------------------------- /gpg/SChernykh.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | 3 | 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 50 | fo0a 51 | =YlLc 52 | -----END PGP PUBLIC KEY BLOCK----- 53 | -------------------------------------------------------------------------------- /gpg/binaryfate.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | 3 | 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 85 | lmE0kDaYQqoBKXNXcybElBID8Q== 86 | =tkJZ 87 | -----END PGP PUBLIC KEY BLOCK----- 88 | -------------------------------------------------------------------------------- /gpg/hinto-janai.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | 3 | mDMEY/uGgxYJKwYBBAHaRw8BAQdAnxjwGrbJPfqAseSO6no55MyV5f71uoEqJr/T 4 | KmLvgT20KGhpbnRvLmphbmFpIDxoaW50by5qYW5haUBwcm90b25tYWlsLmNvbT6I 5 | kAQTFggAOBYhBDHFFFqvpajfHB2yptR84F+hdaSZBQJj+4aDAhsDBQsJCAcCBhUK 6 | CQgLAgQWAgMBAh4BAheAAAoJENR84F+hdaSZh/MBAPtNC4Cs0DcGBr/nwmLxZDGG 7 | 6ZP0beaFjV1AbfzHOSS3AQCIPLFoQonxRTlWGpIeyK5FUn3kMf+eAUDoT9HQisrd 8 | Dbg4BGP7hoMSCisGAQQBl1UBBQEBB0BbtNHDkRLV8zJ5jGtT0DWdfQam2pRp9THf 9 | mctPLlU/EwMBCAeIeAQYFggAIBYhBDHFFFqvpajfHB2yptR84F+hdaSZBQJj+4aD 10 | AhsMAAoJENR84F+hdaSZwhYA/25Cu7D8hIfeCTZ73FJPPqq7teaYQ2/ZvsODYDlF 11 | l8WxAQCytzKQP+vRX6Zh1xIXbYat50lsLyCjgE52J/EG8eiDAA== 12 | =HkB6 13 | -----END PGP PUBLIC KEY BLOCK----- 14 | -------------------------------------------------------------------------------- /gpg/hinto-janaiyo.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | 3 | 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 50 | FfiLDYKYGTw= 51 | =HeCI 52 | -----END PGP PUBLIC KEY BLOCK----- 53 | -------------------------------------------------------------------------------- /gpg/xmrig.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | 3 | mQENBF3VSRIBCADfFjDUbq0WLGulFeSou0A+jTvweNllPyLNOn3SNCC0XLEYyEcu 4 | JiEBK80DlvR06TVr8Aw1rT5S2iH0i5Tl8DqShH2mmcN1rBp1M0Y95D89KVj3BIhE 5 | nxmgmD4N3Wgm+5FmEH4W/RpG1xdYWJx3eJhtWPdFJqpg083E2D5P30wIQem+EnTR 6 | 5YrtTZPh5cPj2KRY+UmsDE3ahmxCgP7LYgnnpZQlWBBiMV932s7MvYBPJQc1wecS 7 | 0wi1zxyS81xHc3839EkA7wueCeNo+5jha+KH66tMKsfrI2WvfPHTCPjK9v7WJc/O 8 | /eRp9d+wacn09D1L6CoRO0ers5p10GO84VhTABEBAAG0GVhNUmlnIDxzdXBwb3J0 9 | QHhtcmlnLmNvbT6JAU4EEwEIADgWIQSaxM6o5m41pcfN3BtEalNji+lECQUCXdVJ 10 | EgIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRBEalNji+lECbkQB/9nRou0 11 | tOlBwYn8xVgBu7IiDWNVETRWfrjrtdTvSahgbbo6lWgjA/vBLkjN9fISdBQ/n/Mt 12 | hNDJbEtxHHt2baJhvT8du1eWcIHHXCV/rmv+iY/hTXa1gKqHiHDJrtYSVBG3BMme 13 | 1rdsUHTiKf3t5yRHOXAfY2C+XNblKAV7mhlxQBiKxdFDIkFEQKNrHNUvnzkOqoCT 14 | 2kTZZ2tPUMQdOn1eek6zG/+C7SwcBpJnakJ8jce4yA/xZbOVKetNWO3Ufu3TE34k 15 | OdA+H4PU9+fV77XfOY8DtXeS3boUI97ei+4s/mwX/NFC0i8CPXyefxl3WRUBGDOI 16 | w//kPNQVh4HobOCeuQENBF3VSRIBCADl29WorEi+vRA/3kg9VUXtxSU6caibFS3N 17 | VXANiFRjrOmICdfrIgOSGNrYCQFsXu0Xe0udDYVX8yX6WJk+CT02Pdg0gkXiKoze 18 | KrnK15mo3xXbb2tr1o9ROPgwY/o2AwQHj0o1JhdS2cybfuRiUQRoGgBX7a9X0cTY 19 | r4ZJvOjzgAajl3ciwB3yWUmDiRlzZpO7YWESXbOhGVzyCnP5MlMEJ/fPRw9h38vK 20 | HNKLhzcRfsLpXk34ghY3SxIv4NWUfuZXFWqpSdC9JgNc5zA72lJEQcF4DHJCKl7B 21 | ddmrfsr9mdiIpo+/ZZFPPngdeZ2kvkJ2YKaZNVu2XooJARPQ8B8tABEBAAGJATYE 22 | GAEIACAWIQSaxM6o5m41pcfN3BtEalNji+lECQUCXdVJEgIbDAAKCRBEalNji+lE 23 | CdPUB/4nH1IdhHGmfko2kxdaHqQgCGLqh3pcrQXD9mBv/LYVnoHZpVRHsIDgg2Z4 24 | lQYrIRRqe69FjVxo7sA2eMIlV0GRDlUrw+HeURFpEhKPEdwFy6i/cti2MY0YxOrB 25 | TvQoRutUoMnyjM4TBJWaaqccbTsavMdLmG3JHdAkiHtUis/fUwVctmEQwN+d/J2b 26 | wJAtliqw3nXchUfdIfwHF/7hg8seUuYUaifzkazBZhVWvRkTVLVanzZ51HRfuzwD 27 | ntaa7kfYGdE+4TKOylAPh+8E6WnR19RRTpsaW0dVBgOiBTE0uc7rUv2HWS/u6RUR 28 | t7ldSBzkuDTlM2V59Iq2hXoSC6dT 29 | =cIG9 30 | -----END PGP PUBLIC KEY BLOCK----- 31 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | # src 2 | monero-bash source file structure: 3 | 4 | | File/Folder | Purpose | 5 | |------------------|-----------------------------------------------| 6 | | `api/` | internal file-based api used by [monero-bash] | 7 | | `func/` | all the functions [monero-bash] uses | 8 | | `txt/` | text files to store long-term on disk | 9 | | `debug.sh` | debugging functions | 10 | | `libtorsocks.so` | builtin torsocks library | 11 | | `source.sh` | master source file that sources vars/funcs | 12 | | `var.sh` | frequently used GLOBAL variables | 13 | 14 | # [monero-bash] order of operations 15 | 1. User inputs [monero-bash \] 16 | 2. [monero-bash] sources -> [source.sh] 17 | 3. [source.sh] sources -> functions, state, variables 18 | 4. `parse_Config()` parses user configs safely 19 | 5. A whole bunch of safety checks 20 | 6. Parse & execute user input (update, wallet, etc) 21 | -------------------------------------------------------------------------------- /src/api/mini: -------------------------------------------------------------------------------- 1 | # env file for [systemd]'s p2pool service file 2 | MINI_FLAG= 3 | -------------------------------------------------------------------------------- /src/debug.sh: -------------------------------------------------------------------------------- 1 | # This file is part of monero-bash - a wrapper for Monero, written in Bash 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # debugging tools for monero-bash 35 | # USE VERY CAREFULLY 36 | 37 | # invoke a monero-bash function directly 38 | DEBUG_04e3be9() 39 | { 40 | BRED; echo "@@@@@@ DEBUG MODE - BE CAREFUL @@@@@@" 41 | IWHITE; echo -n "function to execute: " ;OFF 42 | read command 43 | "$command" 44 | } 45 | 46 | # list all monero-bash functions, variables 47 | LIST() 48 | { 49 | echo -e "\033[1;32mMONERO-BASH GLOBAL FUNCTIONS:\033[0m" 50 | declare -F | sed 's/declare -f //g' 51 | echo -e "\033[1;33mMONERO-BASH GLOBAL VARIABLES:\033[0m" 52 | cat "src/var.sh" | grep -v "#" | grep -v "\033" 53 | } 54 | 55 | # produce a hash list for important monero-bash files /monero-bash/src/txt/hashlist 56 | PRODUCE_HASH_LIST_TEMPLATE() 57 | { 58 | for i in $DIR/* ;do 59 | if [[ -f "$i" && "$i" != "src/txt/hashlist" && "$i" != "src/txt/headers" ]]; then 60 | sudo sha256sum $i >> "$hashlist" 61 | fi 62 | done 63 | } 64 | PRODUCE_HASH_LIST() 65 | { 66 | prompt_Sudo 67 | echo "Producing hashlist..." 68 | sudo echo -n > "$hashlist" 69 | sudo sha256sum "monero-bash" >> "$hashlist" 70 | local DIR="src" 71 | PRODUCE_HASH_LIST_TEMPLATE 72 | local DIR="src/func" 73 | PRODUCE_HASH_LIST_TEMPLATE 74 | local DIR="src/txt" 75 | PRODUCE_HASH_LIST_TEMPLATE 76 | local DIR="config" 77 | PRODUCE_HASH_LIST_TEMPLATE 78 | local DIR="gpg" 79 | PRODUCE_HASH_LIST_TEMPLATE 80 | } 81 | 82 | # check hash list against current monero-bash files (with color coded output) 83 | CHECK_HASH_LIST_TEMPLATE() 84 | { 85 | for i in $DIR/* ;do 86 | if [[ -f "$i" && "$i" != "src/txt/hashlist" ]]; then 87 | grep "$i" "$hashlist" | sha256sum -c &>/dev/null 88 | if [[ $? = "0" ]]; then 89 | BGREEN; printf "[ OK ] " 90 | WHITE; echo "$i" 91 | else 92 | BRED; printf "[FAILED] " 93 | WHITE; echo "$i" 94 | hashFail="true" 95 | fi 96 | fi 97 | done 98 | } 99 | CHECK_HASH_LIST() 100 | { 101 | printf "${BWHITE}${UWHITE}%s${OFF}\n" "[monero-bash] hash integrity" 102 | 103 | # monero-bash hash 104 | grep "monero-bash" "$hashlist" | sha256sum -c &>/dev/null 105 | if [[ $? = "0" ]]; then 106 | BGREEN; printf "[ OK ] " 107 | WHITE; echo "monero-bash" 108 | else 109 | BRED; printf "[FAILED] " 110 | WHITE; echo "monero-bash" 111 | hashFail="true" 112 | fi 113 | 114 | # the rest 115 | local DIR="src" 116 | CHECK_HASH_LIST_TEMPLATE 117 | local DIR="src/func" 118 | CHECK_HASH_LIST_TEMPLATE 119 | local DIR="src/txt" 120 | CHECK_HASH_LIST_TEMPLATE 121 | local DIR="src/config" 122 | CHECK_HASH_LIST_TEMPLATE 123 | local DIR="gpg" 124 | CHECK_HASH_LIST_TEMPLATE 125 | 126 | if [[ $hashFail = "true" ]]; then 127 | BRED; echo -n "monero-bash error: " 128 | BWHITE; echo "hash check has failed" 129 | WHITE; echo "Exiting for safety..." 130 | exit 1 131 | else 132 | return 0 133 | fi 134 | } 135 | 136 | # checks the hash list less verbosely 137 | QUIET_HASH_LIST_TEMPLATE() 138 | { 139 | for i in $DIR/* ;do 140 | if [[ -f "$i" && "$i" != "src/txt/hashlist" ]]; then 141 | if ! grep "$i" "$hashlist" | sha256sum -c &>/dev/null; then 142 | hashFail="true" 143 | localHashFail="true" 144 | fi 145 | fi 146 | done 147 | [[ $localHashFail = true ]] && log::fail "$NAME" 148 | } 149 | QUIET_HASH_LIST() 150 | { 151 | # printf "${BWHITE}${UWHITE}%s${OFF}\n" "[monero-bash] hash integrity" 152 | 153 | # monero-bash hash 154 | if ! grep "monero-bash" "$hashlist" | sha256sum -c &>/dev/null; then 155 | log::fail "monero-bash" 156 | hashFail="true" 157 | fi 158 | 159 | # the rest 160 | local NAME="src" 161 | local DIR="src" 162 | QUIET_HASH_LIST_TEMPLATE 163 | local NAME="func" 164 | local DIR="src/func" 165 | QUIET_HASH_LIST_TEMPLATE 166 | local NAME="txt" 167 | local DIR="src/txt" 168 | QUIET_HASH_LIST_TEMPLATE 169 | local NAME="config" 170 | local DIR="config" 171 | QUIET_HASH_LIST_TEMPLATE 172 | local NAME="gpg" 173 | local DIR="gpg" 174 | QUIET_HASH_LIST_TEMPLATE 175 | 176 | if [[ $hashFail = "true" ]]; then 177 | print_Error_Exit "hash check has failed, exiting for safety" 178 | else 179 | return 0 180 | fi 181 | } 182 | -------------------------------------------------------------------------------- /src/func/backup.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # tar + gpg backups 35 | backup_Wallets() 36 | { 37 | # CHECK IF FILE ALREADY EXISTS 38 | if [[ -f "$dotMoneroBash/backup.tar" ]]; then 39 | print_Error_Exit "$dotMoneroBash/backup.tar already exists!" 40 | elif [[ -f "$dotMoneroBash/backup.tar.gpg" ]]; then 41 | print_Error_Exit "$dotMoneroBash/backup.tar.gpg already exists!" 42 | fi 43 | 44 | # PASSWORD-BASED AES256 ENCRYPTION (output file: backup.tar.gpg) 45 | BBLUE; echo "Backing up wallets..." ;OFF 46 | cd "$dotMoneroBash" || panic 47 | tar -cf "backup.tar" "wallets" --transform 's/wallets/backup/' 48 | gpg --no-symkey-cache --cipher-algo AES256 -c "backup.tar" 49 | if [[ $? != 0 ]]; then 50 | rm "backup.tar" 51 | print_Error_Exit "GPG error" 52 | fi 53 | rm "backup.tar" 54 | BWHITE; echo -n "Cipher algo: " ;OFF; echo "AES256" 55 | BWHITE; echo -n "Key type: " ;OFF; echo "Passphrase" 56 | BWHITE; echo -n "Encrypted wallet tar: " ;OFF; echo "$dotMoneroBash/backup.tar.gpg" 57 | BWHITE; echo -n "To decrypt: " ;BGREEN; echo -n "monero-bash decrypt" 58 | BWHITE; echo -n " OR " ;BGREEN; echo "gpg backup.tar.gpg && tar -xf backup.tar" 59 | } 60 | 61 | backup_Decrypt() 62 | { 63 | [[ -d "$dotMoneroBash/backup" ]]&& print_Error_Exit "$dotMoneroBash/backup already exists, please move!" 64 | [[ -f "$dotMoneroBash/backup.tar" ]]&& print_Error_Exit "$dotMoneroBash/backup.tar already exists!" 65 | [[ ! -f "$dotMoneroBash/backup.tar.gpg" ]]&& print_Error_Exit "$dotMoneroBash/backup.tar.gpg was not found!" 66 | BBLUE; echo "Decrypting backup..." ;OFF 67 | cd "$dotMoneroBash" || panic 68 | gpg --no-symkey-cache "backup.tar.gpg" 69 | error_Exit "Decrypt failed" 70 | tar -xf "backup.tar" 71 | error_Exit "tar failed" 72 | rm "backup.tar" 73 | BWHITE; echo -n "Decrypted backup: " ;OFF; echo "$dotMoneroBash/backup" 74 | } 75 | -------------------------------------------------------------------------------- /src/func/build.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # build folders, files 35 | 36 | # builds everything in monero-bash with default settings 37 | build_Template() 38 | { 39 | prompt_Sudo ; error_Sudo 40 | safety_HashList 41 | mkdir -p "$dotMoneroBash" 42 | permission_InstallDirectory 43 | mkdir -p "$wallets" 44 | sudo -u "$USER" cp -r "$installDirectory/config" "$config" 45 | permission_DotMoneroBash 46 | } 47 | 48 | build_DotMoneroBash() 49 | { 50 | build_Template 51 | } 52 | 53 | # just build monero-bash config 54 | build_Config() 55 | { 56 | prompt_Sudo ; error_Sudo 57 | safety_HashList 58 | permission_installDirectory 59 | sudo -u "$USER" cp -r "$installDirectory/config" "$config" 60 | permission_DotMoneroBash 61 | } 62 | -------------------------------------------------------------------------------- /src/func/code.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # functions that handle exit codes and prints proper messages 35 | code_Wget() 36 | { 37 | case $? in 38 | 0) : ;; 39 | 1|8) print_Error_Exit "wget - Generic error" ;; 40 | 2) print_Error_Exit "wget - Parse error" ;; 41 | 3) print_Error_Exit "wget - File I/O error" ;; 42 | 4) print_Error_Exit "wget - Network failure" ;; 43 | 5) print_Error_Exit "wget - SSL verification failure" ;; 44 | 6) print_Error_Exit "wget - Username/password authentication failure" ;; 45 | 7) print_Error_Exit "wget - Protocol errors" ;; 46 | *) print_Error_Exit "wget - Unknown error" 47 | esac 48 | } 49 | 50 | code_Tar() 51 | { 52 | case $? in 53 | 0) : ;; 54 | 1) print_Error_Exit "tar - Some files differ" ;; 55 | 2) print_Error_Exit "tar - Fatal error" ;; 56 | *) print_Error_Exit "tar - Unknown error" 57 | esac 58 | } 59 | -------------------------------------------------------------------------------- /src/func/compromised.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # messages for when hash/gpg is incorrect 35 | 36 | compromised_Hash() 37 | { 38 | BWHITE; echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 39 | BRED; echo " WARNING: HASH ERROR!" 40 | BRED; echo " [$NAME_PRETTY] hash did not match!" 41 | BRED; echo " [$AUTHOR] might be compromised" 42 | BRED; echo " (or more likely, there was an error)" 43 | BWHITE; echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 44 | BWHITE; echo -n "ONLINE HASH: " ;BBLUE; echo "$HASH" 45 | BWHITE; echo -n "LOCAL HASH: " ;BRED; echo "$LOCAL_HASH" 46 | BRED; echo "EXITING FOR SAFTEY..." 47 | [[ $VERBOSE = "true" ]]&& verbose_Upgrade 48 | exit 1 49 | } 50 | 51 | compromised_GPG() 52 | { 53 | BWHITE; echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 54 | BBLUE; echo " WARNING: GPG SIGNATURE ERROR!" 55 | BBLUE; echo " [$NAME_PRETTY] GPG Signature did not match!" 56 | BBLUE; echo " [$GPG_OWNER] might be compromised" 57 | BBLUE; echo " (or more likely, there was an error)" 58 | BWHITE; echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 59 | BWHITE; echo -n "ONLINE HASH: " ;BBLUE; echo "$HASH" 60 | BWHITE; echo -n "LOCAL HASH: " ;BRED; echo "$LOCAL_HASH" 61 | BWHITE; echo "gpgSTDOUT: " ;OFF; echo "$gpgSTDOUT" 62 | BRED; echo "EXITING FOR SAFTEY..." 63 | [[ $VERBOSE = "true" ]]&& verbose_Upgrade 64 | exit 1 65 | } 66 | -------------------------------------------------------------------------------- /src/func/define.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # defines variables of packages 35 | define_Monero() 36 | { 37 | NAME_VER="$MONERO_VER" 38 | NAME_OLD="$MONERO_OLD" 39 | NAME_PRETTY="Monero" 40 | NAME_FUNC="Monero" 41 | SERVICE="monero-bash-monerod.service" 42 | PROCESS="monerod" 43 | DIRECTORY="$binMonero" 44 | NAME_CAPS="MONERO" 45 | FOLDER="monero" 46 | AUTHOR="monero-project" 47 | PROJECT="monero" 48 | STAR_PKG="monero-linux-x64*" 49 | DOT_PKG="monero-linux-x64.*" 50 | SHA="hashes.txt" 51 | SIG="$SHA" 52 | GPG_OWNER="binaryfate" 53 | GPG_PUB_KEY="https://raw.githubusercontent.com/monero-project/monero/master/utils/gpg_keys/binaryfate.asc" 54 | FINGERPRINT="81AC591FE9C4B65C5806AFC3F0AF4D462A0BDF92" 55 | } 56 | 57 | define_MoneroBash() 58 | { 59 | NAME_VER="$MONERO_BASH_VER" 60 | NAME_OLD="$MONERO_BASH_OLD" 61 | NAME_PRETTY="monero-bash" 62 | NAME_FUNC="MoneroBash" 63 | SERVICE="" 64 | PROCESS="" 65 | DIRECTORY="$installDirectory" 66 | NAME_CAPS="MONERO_BASH" 67 | AUTHOR="hinto-janai" 68 | PROJECT="monero-bash" 69 | STAR_PKG="monero-bash-v*" 70 | DOT_PKG="monero-bash-v.*" 71 | SHA="SHA256SUM" 72 | SIG="$SHA" 73 | GPG_OWNER="hinto-janai" 74 | GPG_PUB_KEY="https://raw.githubusercontent.com/hinto-janai/monero-bash/master/gpg/hinto-janai.asc" 75 | FINGERPRINT="31C5145AAFA5A8DF1C1DB2A6D47CE05FA175A499" 76 | } 77 | 78 | define_XMRig() 79 | { 80 | NAME_VER="$XMRIG_VER" 81 | NAME_OLD="$XMRIG_OLD" 82 | NAME_PRETTY="XMRig" 83 | NAME_FUNC="XMRig" 84 | SERVICE="monero-bash-xmrig.service" 85 | PROCESS="xmrig" 86 | DIRECTORY="$binXMRig" 87 | NAME_CAPS="XMRIG" 88 | FOLDER="xmrig" 89 | AUTHOR="xmrig" 90 | PROJECT="xmrig" 91 | STAR_PKG="xmrig*linux-static-x64*" 92 | DOT_PKG="xmrig.*linux-static-x64.*" 93 | SHA="SHA256SUMS" 94 | SIG="${SHA}.sig" 95 | GPG_OWNER="xmrig" 96 | GPG_PUB_KEY="https://raw.githubusercontent.com/xmrig/xmrig/master/doc/gpg_keys/xmrig.asc" 97 | FINGERPRINT="9AC4CEA8E66E35A5C7CDDC1B446A53638BE94409" 98 | } 99 | 100 | define_P2Pool() 101 | { 102 | NAME_VER="$P2POOL_VER" 103 | NAME_OLD="$P2POOL_OLD" 104 | NAME_PRETTY="P2Pool" 105 | NAME_FUNC="P2Pool" 106 | SERVICE="monero-bash-p2pool.service" 107 | PROCESS="p2pool" 108 | DIRECTORY="$binP2Pool" 109 | NAME_CAPS="P2POOL" 110 | FOLDER="p2pool" 111 | AUTHOR="SChernykh" 112 | PROJECT="p2pool" 113 | STAR_PKG="p2pool*linux-x64*" 114 | DOT_PKG="p2pool.*linux-x64.*" 115 | SHA="sha256sums.txt.asc" 116 | SIG="$SHA" 117 | GPG_OWNER="SChernykh" 118 | GPG_PUB_KEY="https://raw.githubusercontent.com/monero-project/gitian.sigs/master/gitian-pubkeys/SChernykh.asc" 119 | FINGERPRINT="1FCAAB4D3DC3310D16CBD508C47F82B54DA87ADF" 120 | } 121 | -------------------------------------------------------------------------------- /src/func/download.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # order of operations: 35 | # 1. Send request to GitHub API 36 | # 2. Save output as $DUMP variable (to reuse later) 37 | # 3. GitHub will often rate-limit VPNs/Tor: if so, download HTML dump of regular link 38 | # 4. Filter output for latest release download 39 | # 5. wget the found download link 40 | 41 | download_Template() 42 | { 43 | # if API fetch fails, use HTML dump instead 44 | API=true 45 | HTML=false 46 | # Use Tor if specified in [monero-bash.conf] 47 | if [[ $USE_TOR = true ]]; then 48 | if [[ $WGET_GZIP = true ]]; then 49 | DUMP="$(torsocks_func wget -qO- "${WGET_HTTP_HEADERS[@]}" -e robots=off "https://api.github.com/repos/$AUTHOR/$PROJECT/releases/latest" | gzip -d)" 50 | else 51 | DUMP="$(torsocks_func wget -qO- "${WGET_HTTP_HEADERS[@]}" -e robots=off "https://api.github.com/repos/$AUTHOR/$PROJECT/releases/latest")" 52 | fi 53 | else 54 | if [[ $WGET_GZIP = true ]]; then 55 | DUMP="$(wget -qO- "${WGET_HTTP_HEADERS[@]}" -e robots=off "https://api.github.com/repos/$AUTHOR/$PROJECT/releases/latest" | gzip -d)" 56 | else 57 | DUMP="$(wget -qO- "${WGET_HTTP_HEADERS[@]}" -e robots=off "https://api.github.com/repos/$AUTHOR/$PROJECT/releases/latest")" 58 | fi 59 | fi 60 | if [[ $? != 0 ]]; then 61 | IRED; echo "GitHub API error detected..." 62 | OFF; echo "Trying GitHub HTML filter instead..." 63 | if [[ $USE_TOR = true ]]; then 64 | if [[ $WGET_GZIP = true ]]; then 65 | DUMP="$(torsocks_func wget -qO- "${WGET_HTTP_HEADERS[@]}" -e robots=off "https://github.com/$AUTHOR/$PROJECT/releases/latest" | gzip -d)" 66 | else 67 | DUMP="$(torsocks_func wget -qO- "${WGET_HTTP_HEADERS[@]}" -e robots=off "https://github.com/$AUTHOR/$PROJECT/releases/latest")" 68 | fi 69 | else 70 | if [[ $WGET_GZIP = true ]]; then 71 | DUMP="$(wget -qO- "${WGET_HTTP_HEADERS[@]}" -e robots=off "https://github.com/$AUTHOR/$PROJECT/releases/latest" | gzip -d)" 72 | else 73 | DUMP="$(wget -qO- "${WGET_HTTP_HEADERS[@]}" -e robots=off "https://github.com/$AUTHOR/$PROJECT/releases/latest")" 74 | fi 75 | fi 76 | API=false 77 | HTML=true 78 | fi 79 | 80 | # if downloading Monero, just use the static getmonero.org link 81 | if [[ $downloadMonero = true ]]; then 82 | LINK="https://downloads.getmonero.org/cli/linux64" 83 | if [[ $USE_TOR = true ]]; then 84 | torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -P "$tmp" -q --show-progress --content-disposition "$LINK" 85 | else 86 | wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -P "$tmp" -q --show-progress --content-disposition "$LINK" 87 | fi 88 | code_Wget 89 | else 90 | 91 | # else, search for the download link on github 92 | if [[ $HTML = true ]]; then 93 | LINK="$(echo "$DUMP" \ 94 | | grep -o "/$AUTHOR/$PROJECT/releases/download/.*/$DOT_PKG" \ 95 | | awk '{print $1}' \ 96 | | tr -d '"' \ 97 | | sed 's@^@https://github.com@')" 98 | else 99 | LINK="$(echo "$DUMP" \ 100 | | json::var \ 101 | | grep -o "https://github.com/$AUTHOR/$PROJECT/releases/download/.*/$DOT_PKG" \ 102 | | tr -d '"')" 103 | fi 104 | if [[ $USE_TOR = true ]]; then 105 | torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -P "$tmp" -q --show-progress "$LINK" 106 | else 107 | wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -P "$tmp" -q --show-progress "$LINK" 108 | fi 109 | code_Wget 110 | fi 111 | } 112 | -------------------------------------------------------------------------------- /src/func/edit.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # for edit configs and systemd services 35 | 36 | edit_Config() 37 | { 38 | if [[ -z $EDITOR ]]; then 39 | print_Warn "No default \$EDITOR found!" 40 | OFF; printf "Pick editor [nano, vim, emacs, etc] (default=nano): " 41 | read EDITOR 42 | [[ -z $EDITOR || $EDITOR = "default" ]] && EDITOR="nano" 43 | fi 44 | 45 | case $NAME_PRETTY in 46 | monero-bash) $EDITOR "$config/monero-bash.conf";; 47 | Monero) 48 | case $EDIT_CONFIG in 49 | daemon) $EDITOR "$config/monerod.conf";; 50 | wallet) $EDITOR "$config/monero-wallet-cli.conf";; 51 | *) $EDITOR "$config/monerod.conf" "$config/monero-wallet-cli.conf";; 52 | esac 53 | ;; 54 | XMRig) $EDITOR "$xmrigConf";; 55 | P2Pool) $EDITOR "$config/p2pool.conf";; 56 | esac 57 | } 58 | 59 | edit_Systemd() 60 | { 61 | prompt_Sudo;error_Sudo 62 | if [[ -z $EDITOR ]]; then 63 | print_Warn "No default \$EDITOR found!" 64 | OFF; printf "Pick editor [nano, vim, emacs, etc] (default=nano): " 65 | read EDITOR 66 | [[ -z $EDITOR || $EDITOR = "default" ]] && EDITOR="nano" 67 | fi 68 | 69 | sudo "$EDITOR" "$sysd/$SERVICE" 70 | if [[ $? = 0 ]]; then 71 | OFF; echo "Reloading [systemd]..." 72 | sudo systemctl daemon-reload 73 | else 74 | print_Error "[systemd] changes failed" 75 | fi 76 | } 77 | -------------------------------------------------------------------------------- /src/func/eol.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # End-Of-Life 35 | # ----------- 36 | # Warn user if their [monero-bash] version 37 | # is an old unsupported version. 38 | 39 | ___END___OF___LIFE___() { 40 | API=false 41 | HTML=true 42 | if [[ $USE_TOR = true ]]; then 43 | if ! DUMP="$(torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- "https://api.github.com/repos/$AUTHOR/$PROJECT/releases/latest")"; then 44 | DUMP="$(torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- "https://github.com/$AUTHOR/$PROJECT/releases/latest")" 45 | API=false 46 | HTML=true 47 | fi 48 | else 49 | if ! DUMP="$(wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- "https://api.github.com/repos/$AUTHOR/$PROJECT/releases/latest")"; then 50 | DUMP="$(wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- "https://github.com/$AUTHOR/$PROJECT/releases/latest")" 51 | API=false 52 | HTML=true 53 | fi 54 | fi 55 | version_Template 56 | if [[ $NewVer != v1* ]]; then 57 | printf "\033[1;31m%s\n"\ 58 | "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"\ 59 | "@ This version of [monero-bash] is no @"\ 60 | "@ longer supported ($MONERO_BASH_VER). @"\ 61 | "@ Every major version change, e.g: @"\ 62 | "@ v1.0.0 > v2.0.0 contains changes @"\ 63 | "@ that break backwards compatability. @"\ 64 | "@ @"\ 65 | "@ You are free to continue to use @"\ 66 | "@ this version, but be aware you will @"\ 67 | "@ not be able to upgrade monero-bash @"\ 68 | "@ and may face bugs in the future. @"\ 69 | "@ @"\ 70 | "@ Please move your .bitmonero, wallet @"\ 71 | "@ and config folders outside of the @"\ 72 | "@ [.monero-bash] folder and then @"\ 73 | "@ uninstall this monero-bash with: @"\ 74 | "@ \"monero-bash uninstall\" @"\ 75 | "@ then, you can reinstall the @"\ 76 | "@ latest version from: @@@@@@@@@@"\ 77 | "@ https://github.com/hinto-janai/monero-bash @"\ 78 | "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 79 | exit 1 80 | fi 81 | } 82 | -------------------------------------------------------------------------------- /src/func/error.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # Error handling 35 | error_Continue(){ [[ $? != 0 ]] && printf "\e[1;31m%s\e[0;97m%s\e[0m\n" "[monero-bash error] " "$1"; } 36 | 37 | error_Exit() { 38 | if [[ $? != 0 ]]; then 39 | printf "\e[1;91m%s\e[0;97m%s\e[0m\n" "[monero-bash error] " "$1" 40 | exit 1 41 | fi 42 | } 43 | 44 | error_Sudo() 45 | { 46 | if [[ $? != "0" ]]; then 47 | printf "\e[1;91m%s\e[0;97m%s\e[0m\n" "[monero-bash error] " " is needed" 48 | exit 1 49 | fi 50 | } 51 | 52 | 53 | error_Unknown() 54 | { 55 | printf "\e[1;91m%s\e[0;97m%s\e[0m\n" "[monero-bash error] " "Unknown command" 56 | exit 1 57 | } 58 | 59 | error_Trap() 60 | { 61 | echo 62 | printf "\e[1;91m%s\e[1;97m%s\e[0m\n" "[monero-bash] " "Exit signal caught - $1" 63 | } 64 | -------------------------------------------------------------------------------- /src/func/gpg.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # gpg functions for: 35 | # -importing gpgs keys 36 | # -checking LOCAL/ONLINE diff 37 | # -overwriting LOCAL keys with ONLINE 38 | 39 | gpg_import_Template() 40 | { 41 | local LOCAL="$(cat "$installDirectory/gpg/${GPG_OWNER}.asc")" 42 | if [[ $USE_TOR = true ]]; then 43 | if [[ $WGET_GZIP = true ]]; then 44 | local ONLINE="$(torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- "$GPG_PUB_KEY" | gzip -d)" 45 | else 46 | local ONLINE="$(torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- "$GPG_PUB_KEY")" 47 | fi 48 | else 49 | if [[ $WGET_GZIP = true ]]; then 50 | local ONLINE="$(wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- "$GPG_PUB_KEY" | gzip -d)" 51 | else 52 | local ONLINE="$(wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- "$GPG_PUB_KEY")" 53 | fi 54 | fi 55 | code_Wget 56 | if [[ $LOCAL = "$ONLINE" ]]; then 57 | gpg --import "$installDirectory/gpg/${GPG_OWNER}.asc" 58 | else 59 | gpg_Diff 60 | fi 61 | } 62 | 63 | gpg_import_Monero() 64 | { 65 | define_Monero 66 | gpg_import_Template 67 | } 68 | 69 | gpg_import_MoneroBash() 70 | { 71 | define_MoneroBash 72 | gpg_import_Template 73 | } 74 | 75 | gpg_import_XMRig() 76 | { 77 | define_XMRig 78 | gpg_import_Template 79 | } 80 | 81 | gpg_import_P2Pool() 82 | { 83 | define_P2Pool 84 | gpg_import_Template 85 | } 86 | gpg_import_All() 87 | { 88 | gpg_import_Monero 89 | gpg_import_MoneroBash 90 | gpg_import_XMRig 91 | gpg_import_P2Pool 92 | } 93 | 94 | gpg_Diff() 95 | { 96 | BWHITE; echo -n "The LOCAL and ONLINE gpg keys of " 97 | BRED; echo -n "$GPG_OWNER " 98 | BWHITE; echo "are different!" ;OFF 99 | BBLUE; echo -n "LOCAL: " 100 | OFF; echo "$installDirectory/gpg/${GPG_OWNER}.asc" 101 | BGREEN; echo -n "ONLINE: " 102 | OFF; echo "$GPG_PUB_KEY" 103 | while true ;do 104 | BWHITE; echo -n "What to do? [show / pick / skip] " ;OFF 105 | read OPTION 106 | case $OPTION in 107 | show) 108 | BBLUE; echo "LOCAL KEY:" 109 | OFF; echo "$LOCAL" 110 | BGREEN; echo "ONLINE KEY:" 111 | OFF; echo "$ONLINE" 112 | ;; 113 | pick) 114 | while true; do 115 | BWHITE; echo -n "Which key to pick? [local / online] " ;OFF 116 | read KEYPICK 117 | case $KEYPICK in 118 | local) gpg --import "$installDirectory/gpg/${GPG_OWNER}.asc" && break ;; 119 | online) gpg_Overwrite && break ;; 120 | *) print_Error "Invalid option" 121 | esac 122 | done 123 | break 124 | ;; 125 | skip) 126 | BWHITE; echo "Skipping..." 127 | echo 128 | break 129 | ;; 130 | *) 131 | error_Continue "Invalid option" 132 | ;; 133 | esac 134 | done 135 | } 136 | 137 | gpg_Overwrite() 138 | { 139 | prompt_Sudo 140 | error_Sudo 141 | safety_HashList 142 | BWHITE; echo "Overwriting LOCAL keys..." ;OFF 143 | trap "trap_Hash" 1 2 3 6 15 144 | if [[ $USE_TOR = true ]]; then 145 | if [[ $WGET_GZIP = true ]]; then 146 | torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -q -O "$installDirectory/gpg/${GPG_OWNER}.asc" "$GPG_PUB_KEY" | gzip -d 147 | else 148 | torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -q -O "$installDirectory/gpg/${GPG_OWNER}.asc" "$GPG_PUB_KEY" 149 | fi 150 | else 151 | if [[ $WGET_GZIP = true ]]; then 152 | wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -q -O "$installDirectory/gpg/${GPG_OWNER}.asc" "$GPG_PUB_KEY" | gzip -d 153 | else 154 | wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -q -O "$installDirectory/gpg/${GPG_OWNER}.asc" "$GPG_PUB_KEY" 155 | fi 156 | fi 157 | code_Wget 158 | PRODUCE_HASH_LIST 159 | local LOCAL="$(cat "$installDirectory/gpg/${GPG_OWNER}.asc")" 160 | gpg_import_Template 161 | } 162 | -------------------------------------------------------------------------------- /src/func/install.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # install functions 35 | install_Template() 36 | { 37 | if [[ $NAME_VER ]]; then 38 | OFF; echo -n "$NAME_PRETTY ($NAME_VER) " 39 | OFF; echo "is already installed" 40 | exit 1 41 | else 42 | local INSTALL="true" 43 | upgrade_"$NAME_FUNC" 44 | fi 45 | } 46 | 47 | install_MoneroBash() 48 | { 49 | define_MoneroBash 50 | install_Template 51 | } 52 | 53 | install_Monero() 54 | { 55 | define_Monero 56 | install_Template 57 | } 58 | 59 | install_XMRig() 60 | { 61 | define_XMRig 62 | install_Template 63 | } 64 | 65 | install_P2Pool() 66 | { 67 | define_P2Pool 68 | install_Template 69 | } 70 | 71 | install_All() 72 | { 73 | [[ $MONERO_VER = "" ]]&& install_Monero 74 | [[ $XMRIG_VER = "" ]]&& install_XMRig 75 | [[ $P2POOL_VER = "" ]]&& install_P2Pool 76 | } 77 | -------------------------------------------------------------------------------- /src/func/libconfig.sh: -------------------------------------------------------------------------------- 1 | # libconfig.sh 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | #git 24 | 25 | config::grep() { 26 | # init local variables 27 | local i LIBCONFIG_FILE LIBCONFIG_ARG LIBCONFIG_OUTPUT_TYPE LIBCONFIG_OUTPUT_MOD IFS=$'\n' || return 1 28 | declare -a LIBCONFIG_ARRAY LIBCONFIG_OUTPUT || return 1 29 | 30 | # check for correct arguments 31 | [[ $# -lt 3 ]] && return 2 32 | 33 | # parse args 34 | case $1 in 35 | --prefix=*|--map=*) 36 | # check for even arguments 37 | LIBCONFIG_ARG=$(($# % 2)) 38 | [[ $LIBCONFIG_ARG = 0 ]] || return 3 39 | LIBCONFIG_OUTPUT_TYPE="$1" 40 | LIBCONFIG_FILE="$2" 41 | shift 2 42 | ;; 43 | *) 44 | # check for odd arguments 45 | LIBCONFIG_ARG=$(($# % 2)) 46 | [[ $LIBCONFIG_ARG = 1 ]] || return 3 47 | LIBCONFIG_FILE="$1" 48 | shift 1 49 | ;; 50 | esac 51 | 52 | # check if config is a file 53 | [[ -f $LIBCONFIG_FILE ]] || return 4 54 | # check for read permission 55 | [[ -r $LIBCONFIG_FILE ]] || return 5 56 | 57 | # create line array of file 58 | mapfile LIBCONFIG_ARRAY < "$LIBCONFIG_FILE" || return 6 59 | # strip quotes 60 | LIBCONFIG_ARRAY=(${LIBCONFIG_ARRAY[@]//\"}) 61 | LIBCONFIG_ARRAY=(${LIBCONFIG_ARRAY[@]//\'}) 62 | 63 | # determine output type 64 | case $LIBCONFIG_OUTPUT_TYPE in 65 | --map=*) LIBCONFIG_OUTPUT_MOD="${LIBCONFIG_OUTPUT_TYPE/*=}"; LIBCONFIG_OUTPUT_TYPE=map;; 66 | --prefix=*) LIBCONFIG_OUTPUT_MOD="${LIBCONFIG_OUTPUT_TYPE/*=}"; LIBCONFIG_OUTPUT_TYPE=prefix;; 67 | esac 68 | 69 | # loop over arguments 70 | until [[ $# = 0 ]]; do 71 | # loop over file per argument given 72 | for i in ${LIBCONFIG_ARRAY[@]}; do 73 | # continue if basic pattern does not match 74 | [[ $i = ${2}* ]] || continue 75 | # else case the data type and check for match 76 | case $1 in 77 | ip) [[ $i =~ ^${2}=localhost$ || $i =~ ^${2}=[[:alnum:].]+'.'[[:alnum:]]+$ ]] && LIBCONFIG_OUTPUT+=("${2//-/_}=${i/*=/}");; 78 | port) [[ $i =~ ^${2}=localhost':'[0-9]+$ || $i =~ ^${2}=[[:alnum:].]+'.'[[:alnum:]]+':'[0-9]+$ ]] && LIBCONFIG_OUTPUT+=("${2//-/_}=${i/*=/}");; 79 | int) [[ $i =~ ^${2}=[0-9]+$ || $i =~ ^${2}=-[0-9]+$ ]] && LIBCONFIG_OUTPUT+=("${2//-/_}=${i/*=/}");; 80 | pos) [[ $i =~ ^${2}=[0-9]+$ ]] && LIBCONFIG_OUTPUT+=("${2//-/_}=${i/*=/}");; 81 | neg) [[ $i =~ ^${2}=-[0-9]+$ ]] && LIBCONFIG_OUTPUT+=("${2//-/_}=${i/*=/}");; 82 | bool) [[ $i =~ ^${2}=true$ || $i =~ ^${2}=false$ ]] && LIBCONFIG_OUTPUT+=("${2//-/_}=${i/*=/}");; 83 | char) [[ $i =~ ^${2}=[[:alnum:]._-]+$ ]] && LIBCONFIG_OUTPUT+=("${2//-/_}=${i/*=/}");; 84 | path) [[ $i =~ ^${2}=[[:alnum:]./_-]+$ ]] && LIBCONFIG_OUTPUT+=("${2//-/_}=${i/*=/}");; 85 | proto) [[ $i =~ ^${2}=[[:alpha:]]+://[[:alnum:]./?=_%:-]+$ || $i =~ ^${2}=[[:alpha:]]+://[[:alnum:]./?=_%:-]+':'[0-9]+$ ]] && LIBCONFIG_OUTPUT+=("${2//-/_}=${i/*=/}");; 86 | web) [[ $i =~ ^${2}='http://'[[:alnum:]./?=_%:-]+$ || $i =~ ^${2}='https://'[[:alnum:]./?=_%:-]+$ || $i =~ ^${2}='www.'[[:alnum:]./?=_%:-]+$ ]] && LIBCONFIG_OUTPUT+=("${2//-/_}=${i/*=/}");; 87 | any) 88 | if [[ $i =~ ^${2}=.*$ ]]; then 89 | [[ ${i/${2}=} ]] && LIBCONFIG_OUTPUT+=("${2//-/_}=${i/*=/}") 90 | fi;; 91 | \[*\]*|\(*\)*) LIBCONFIG_RANGE="$1" && [[ $i =~ ^${2}=${LIBCONFIG_RANGE}$ ]] && LIBCONFIG_OUTPUT+=("${2//-/_}=${i/*=/}");; 92 | *) return 7;; 93 | esac 94 | done 95 | shift 2 96 | done 97 | 98 | # return error on nothing found 99 | [[ $LIBCONFIG_OUTPUT ]] || return 8 100 | 101 | # determine output type 102 | case $LIBCONFIG_OUTPUT_TYPE in 103 | prefix) printf "${LIBCONFIG_OUTPUT_MOD}%s\n" "${LIBCONFIG_OUTPUT[@]}";; 104 | map) printf "${LIBCONFIG_OUTPUT_MOD}[%s\n" "${LIBCONFIG_OUTPUT[@]/=/\]=}";; 105 | *) printf "%s\n" "${LIBCONFIG_OUTPUT[@]}";; 106 | esac 107 | } 108 | 109 | config::merge() { 110 | # init local variables. 111 | local i IFS=$'\n' || return 1 112 | local -a LIBCONFIG_OLD LIBCONFIG_CMD || return 2 113 | 114 | # check amount of arguments 115 | case $# in 116 | 2) :;; 117 | *) return 3 118 | esac 119 | 120 | # check if file 121 | [[ -f $1 ]] || return 3 122 | [[ -f $2 ]] || return 4 123 | 124 | # check for read permission 125 | [[ -r $1 ]] || return 5 126 | [[ -r $2 ]] || return 6 127 | 128 | # get old values from (a) in memory 129 | LIBCONFIG_OLD=($(sed "/^#.*/d; /^$/d; s@/@\\\/@g; s/'//g; s/\"//g; s/\[/\\\[/g; s/\]/\\\]/g" "$1" | grep "^.*=.*$")) || return 7 130 | 131 | # create the find/replace argument in one 132 | # line instead of invoking sed every loop 133 | # account for commented out values as well. 134 | for i in ${LIBCONFIG_OLD[@]}; do 135 | if [[ $i = *' '* ]]; then 136 | LIBCONFIG_CMD+=("-e s/^${i/=*}.*$/${i/=*/=}\"${i/*=}\"/g" "-e s/^#\+${i/=*}.*$/${i/=*/=}\"${i/*=}\"/g") 137 | else 138 | LIBCONFIG_CMD+=("-e s/^${i/=*/=}.*$/${i}/g" "-e s/^#\+${i/=*/=}.*$/${i}/g") 139 | fi 140 | done 141 | 142 | # invoke sed once, with the long argument we just created 143 | LIBCONFIG_CMD=(sed "${LIBCONFIG_CMD[@]}" "$2") 144 | "${LIBCONFIG_CMD[@]}" 145 | } 146 | -------------------------------------------------------------------------------- /src/func/libjson.sh: -------------------------------------------------------------------------------- 1 | # libjson.sh 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this library are orignally: 24 | # Copyright (c) 2011-2022, Dominic Tarr 25 | 26 | #git 27 | 28 | # Parse JSON with Bash + Grep/AWK 29 | # Input must be piped in, no args. 30 | # Taken from: https://github.com/dominictarr/JSON.sh 31 | # and modified slightly to work as a function and to 32 | # use more widely adopted UNIX tool versions, Debian 33 | # need these changes: gawk -> awk, egrep -> grep -E 34 | json::sh() { 35 | json::throw() { 36 | echo "$*" >&2 37 | return 1 38 | } 39 | 40 | BRIEF=0 41 | LEAFONLY=0 42 | PRUNE=0 43 | NO_HEAD=0 44 | NORMALIZE_SOLIDUS=0 45 | 46 | json::usage() { 47 | echo 48 | echo "Usage: JSON.sh [-b] [-l] [-p] [-s] [-h]" 49 | echo 50 | echo "-p - Prune empty. Exclude fields with empty values." 51 | echo "-l - Leaf only. Only show leaf nodes, which stops data duplication." 52 | echo "-b - Brief. Combines 'Leaf only' and 'Prune empty' options." 53 | echo "-n - No-head. Do not show nodes that have no path (lines that start with [])." 54 | echo "-s - Remove escaping of the solidus symbol (straight slash)." 55 | echo "-h - This help text." 56 | echo 57 | } 58 | 59 | json::parse_options() { 60 | set -- "$@" 61 | local ARGN=$# 62 | while [ "$ARGN" -ne 0 ] 63 | do 64 | case $1 in 65 | -h) json::usage 66 | return 0 67 | ;; 68 | -b) BRIEF=1 69 | LEAFONLY=1 70 | PRUNE=1 71 | ;; 72 | -l) LEAFONLY=1 73 | ;; 74 | -p) PRUNE=1 75 | ;; 76 | -n) NO_HEAD=1 77 | ;; 78 | -s) NORMALIZE_SOLIDUS=1 79 | ;; 80 | ?*) echo "ERROR: Unknown option." 81 | json::usage 82 | return 0 83 | ;; 84 | esac 85 | shift 1 86 | ARGN=$((ARGN-1)) 87 | done 88 | } 89 | 90 | json::awk_egrep() { 91 | local pattern_string=$1 92 | 93 | awk '{ 94 | while ($0) { 95 | start=match($0, pattern); 96 | token=substr($0, start, RLENGTH); 97 | print token; 98 | $0=substr($0, start+RLENGTH); 99 | } 100 | }' pattern="$pattern_string" 101 | } 102 | 103 | json::tokenize() { 104 | local ESCAPE 105 | local CHAR 106 | 107 | if echo "test string" | grep -E -ao --color=never "test" >/dev/null 2>&1 108 | then 109 | json::grep() { grep -E -ao --color=never "$@"; } 110 | else 111 | json::grep() { grep -E -ao "$@"; } 112 | fi 113 | 114 | if echo "test string" | grep -E -o "test" >/dev/null 2>&1 115 | then 116 | ESCAPE='(\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})' 117 | CHAR='[^[:cntrl:]"\\]' 118 | else 119 | json::grep() { json::awk_egrep "$@"; } 120 | ESCAPE='(\\\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})' 121 | CHAR='[^[:cntrl:]"\\\\]' 122 | fi 123 | 124 | local STRING="\"$CHAR*($ESCAPE$CHAR*)*\"" 125 | local NUMBER='-?(0|[1-9][0-9]*)([.][0-9]*)?([eE][+-]?[0-9]*)?' 126 | local KEYWORD='null|false|true' 127 | local SPACE='[[:space:]]+' 128 | 129 | # Force zsh to expand $A into multiple words 130 | local is_wordsplit_disabled=$(unsetopt 2>/dev/null | grep -c '^shwordsplit$') 131 | if [ $is_wordsplit_disabled != 0 ]; then setopt shwordsplit; fi 132 | json::grep "$STRING|$NUMBER|$KEYWORD|$SPACE|." | grep -E -v "^$SPACE$" 133 | if [ $is_wordsplit_disabled != 0 ]; then unsetopt shwordsplit; fi 134 | } 135 | 136 | json::parse_array() { 137 | local index=0 138 | local ary='' 139 | read -r token 140 | case "$token" in 141 | ']') ;; 142 | *) 143 | while : 144 | do 145 | json::parse_value "$1" "$index" 146 | index=$((index+1)) 147 | ary="$ary""$value" 148 | read -r token 149 | case "$token" in 150 | ']') break ;; 151 | ',') ary="$ary," ;; 152 | *) json::throw "EXPECTED , or ] GOT ${token:-EOF}" ;; 153 | esac 154 | read -r token 155 | done 156 | ;; 157 | esac 158 | [ "$BRIEF" -eq 0 ] && value=$(printf '[%s]' "$ary") || value= 159 | : 160 | } 161 | 162 | json::parse_object() { 163 | local key 164 | local obj='' 165 | read -r token 166 | case "$token" in 167 | '}') ;; 168 | *) 169 | while : 170 | do 171 | case "$token" in 172 | '"'*'"') key=$token ;; 173 | *) json::throw "EXPECTED string GOT ${token:-EOF}" ;; 174 | esac 175 | read -r token 176 | case "$token" in 177 | ':') ;; 178 | *) json::throw "EXPECTED : GOT ${token:-EOF}" ;; 179 | esac 180 | read -r token 181 | json::parse_value "$1" "$key" 182 | obj="$obj$key:$value" 183 | read -r token 184 | case "$token" in 185 | '}') break ;; 186 | ',') obj="$obj," ;; 187 | *) json::throw "EXPECTED , or } GOT ${token:-EOF}" ;; 188 | esac 189 | read -r token 190 | done 191 | ;; 192 | esac 193 | [ "$BRIEF" -eq 0 ] && value=$(printf '{%s}' "$obj") || value= 194 | : 195 | } 196 | 197 | json::parse_value() { 198 | local jpath="${1:+$1,}$2" isleaf=0 isempty=0 print=0 199 | case "$token" in 200 | '{') json::parse_object "$jpath" ;; 201 | '[') json::parse_array "$jpath" ;; 202 | # At this point, the only valid single-character tokens are digits. 203 | ''|[!0-9]) json::throw "EXPECTED value GOT ${token:-EOF}" ;; 204 | *) value=$token 205 | # if asked, replace solidus ("\/") in json strings with normalized value: "/" 206 | [ "$NORMALIZE_SOLIDUS" -eq 1 ] && value=$(echo "$value" | sed 's#\\/#/#g') 207 | isleaf=1 208 | [ "$value" = '""' ] && isempty=1 209 | ;; 210 | esac 211 | [ "$value" = '' ] && return 212 | [ "$NO_HEAD" -eq 1 ] && [ -z "$jpath" ] && return 213 | 214 | [ "$LEAFONLY" -eq 0 ] && [ "$PRUNE" -eq 0 ] && print=1 215 | [ "$LEAFONLY" -eq 1 ] && [ "$isleaf" -eq 1 ] && [ $PRUNE -eq 0 ] && print=1 216 | [ "$LEAFONLY" -eq 0 ] && [ "$PRUNE" -eq 1 ] && [ "$isempty" -eq 0 ] && print=1 217 | [ "$LEAFONLY" -eq 1 ] && [ "$isleaf" -eq 1 ] && \ 218 | [ $PRUNE -eq 1 ] && [ $isempty -eq 0 ] && print=1 219 | [ "$print" -eq 1 ] && printf "[%s]\t%s\n" "$jpath" "$value" 220 | : 221 | } 222 | 223 | json::parse() { 224 | read -r token 225 | json::parse_value 226 | read -r token 227 | case "$token" in 228 | '') ;; 229 | *) json::throw "EXPECTED EOF GOT $token" ;; 230 | esac 231 | } 232 | 233 | json::parse_options "$@" 234 | json::tokenize | json::parse 235 | } 236 | 237 | # This function parses json::sh() output and turns it into 238 | # a text list of standard Shell variable declaration, e.g: 239 | # JSON: 240 | # ----- 241 | # { 242 | # "id": "0", 243 | # "jsonrpc": "2.0", 244 | # "result": { 245 | # "block_header": { 246 | # "block_size": 80, 247 | # 248 | # json::sh() output: 249 | # ------------------ 250 | # ["id"] "0" 251 | # ["jsonrpc"] "2.0" 252 | # ["result","block_header","block_size"] 80 253 | # 254 | # json::var() output: 255 | # ------------------- 256 | # id=0 257 | # jsonrpc=2.0 258 | # result_block_header_block_size=80 259 | # 260 | # This is now in a form where 261 | # Bash can easily source it. 262 | json::var() { json::sh -l | sed "s/\[\"//g; s/\"\]\t\"/=/g; s/\"$//g; s/\"\]\t/=/g; s/\",\"/_/g; s/\",/_/g; s/,\"/_/g; s/={/='{/g; s/}$/}'/g"; } 263 | 264 | # This turns json::var() 265 | # output into a single line 266 | # which allows you to do this: 267 | # 268 | # local $(json::line < file.json) 269 | # 270 | # Now all the JSON values will be 271 | # declared as local variables all 272 | # at once, no looping. 273 | json::line() { local -a LIBJSON_LINE=($(json::var)); echo ${LIBJSON_LINE[@]}; } 274 | 275 | # This creates GLOBAL variables. 276 | json::source() { source <(json::var); } 277 | -------------------------------------------------------------------------------- /src/func/log.sh: -------------------------------------------------------------------------------- 1 | # This file is part of stdlib.sh - a standard library for Bash 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | #git 24 | 25 | # log() 26 | # ----- 27 | # print formatted 28 | # messages to the terminal. 29 | # the line is first cleared then 30 | # the message is printed. this is to 31 | # avoid previous messages (from log::prog) 32 | # from leaving traces. can take 33 | # multiple inputs, each input will 34 | # be formatted and print a newline. 35 | 36 | log::ok() { printf "\r\e[2K\e[1;32m[ OK ]\e[0m %s\n" "$@"; } 37 | log::info() { printf "\r\e[2K\e[1;37m[ INFO ]\e[0m %s\n" "$@"; } 38 | log::warn() { printf "\r\e[2K\e[1;33m[ WARN ]\e[0m %s\n" "$@"; } 39 | log::fail() { printf "\r\e[2K\e[1;31m[ FAIL ]\e[0m %s\n" "$@"; } 40 | log::danger() { printf "\r\e[2K\e[1;31m[DANGER]\e[0m %s\n" "$@"; } 41 | 42 | # format with 8 spaces instead of [] 43 | log::tab() { printf "\r\e[2K\e[0m %s\n" "$@"; } 44 | 45 | # do not print a newline, leave cursor at the end. 46 | # printing a different log:: will overwrite this one. 47 | log::prog() { printf "\r\e[2K\e[1;37m[ \e[0m....\e[1;37m ]\e[0m %s " "$@"; } 48 | -------------------------------------------------------------------------------- /src/func/mine.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # all-in-one mining functions 35 | # invoked by "monero-bash all" 36 | 37 | mine_Start() 38 | { 39 | prompt_Sudo;error_Sudo 40 | [[ $AUTO_HUGEPAGES = true ]] && mine_Hugepages 41 | [[ $MONERO_VER ]] && missing_Monero && define_Monero && process_Start 42 | [[ $P2POOL_VER ]] && missing_P2Pool && define_P2Pool && process_Start 43 | [[ $XMRIG_VER ]] && missing_XMRig && define_XMRig && process_Start 44 | printf "Watch with: " 45 | BWHITE; echo "[monero-bash watch ]" ;OFF 46 | return 0 47 | } 48 | 49 | mine_Stop() 50 | { 51 | prompt_Sudo;error_Sudo 52 | [[ $MONERO_VER ]] && define_Monero && process_Stop 53 | [[ $P2POOL_VER ]] && define_P2Pool && process_Stop 54 | [[ $XMRIG_VER ]] && define_XMRig && process_Stop 55 | return 0 56 | } 57 | 58 | mine_Restart() 59 | { 60 | prompt_Sudo;error_Sudo 61 | [[ $MONERO_VER ]] && define_Monero && process_Restart 62 | [[ $P2POOL_VER ]] && define_P2Pool && process_Restart 63 | [[ $XMRIG_VER ]] && define_XMRig && process_Restart 64 | return 0 65 | } 66 | 67 | mine_Hugepages() 68 | { 69 | # set default if not specified in monero-bash.conf 70 | [[ -z $HUGEPAGES ]] && HUGEPAGES="3072" 71 | BWHITE; echo "Setting hugepage: $HUGEPAGES" ;OFF 72 | sudo sysctl vm.nr_hugepages="$HUGEPAGES" > /dev/null 73 | error_Continue "Could not set hugepages..." 74 | } 75 | 76 | mine_Config() 77 | { 78 | while :; do 79 | BRED; echo "#-----------------------------------------#" 80 | BRED; echo "# P2Pool & XMRig mining configuration #" 81 | BRED; echo "#-----------------------------------------#" 82 | 83 | # wallet + daemon ip + pool ip + mini config 84 | unset -v WALLET IP RPC ZMQ POOL MINI LOG OUT_PEERS IN_PEERS 85 | while :; do 86 | BWHITE; printf "WALLET ADDRESS: " ;OFF 87 | read -r WALLET 88 | if [[ $WALLET ]]; then 89 | break 90 | else 91 | print_Error "Empty input!" 92 | fi 93 | done 94 | echo 95 | 96 | UYELLOW; BYELLOW; printf "%s\n" "Hit [enter] to select the [default] if you don't know what to input." 97 | IWHITE; printf "Pool IP [default: 127.0.0.1:3333] | " ;OFF 98 | read -r POOL 99 | IWHITE; printf "Monero Node IP [default: 127.0.0.1] | " ;OFF 100 | read -r DAEMON_IP 101 | IWHITE; printf "Monero RPC port [default: 18081] | " ;OFF 102 | read -r DAEMON_RPC 103 | IWHITE; printf "Monero ZMQ port [default: 18083] | " ;OFF 104 | read -r DAEMON_ZMQ 105 | IWHITE; printf "P2Pool OUT peers (10-450) [default: 10] | " ;OFF 106 | read -r OUT_PEERS 107 | IWHITE; printf "P2Pool IN peers (10-450) [default: 10] | " ;OFF 108 | read -r IN_PEERS 109 | IWHITE; printf "P2Pool Log Level (0-6) [default: 3] | " ;OFF 110 | read -r LOG_LEVEL 111 | IWHITE; printf "Use P2Pool Mini-Pool? (Y/n) | " ;OFF 112 | Yes(){ MINI="true" ;} 113 | No(){ MINI="false" ;} 114 | prompt_YESno 115 | echo 116 | 117 | # repeat & confirm user input 118 | BBLUE; printf "WALLET ADDRESS | " ;OFF; echo "$WALLET" 119 | 120 | BBLUE; printf "POOL IP | " ;OFF 121 | [[ $POOL ]] || POOL="127.0.0.1:3333" 122 | echo "$POOL" 123 | 124 | BBLUE; printf "MONERO NODE IP | " ;OFF 125 | [[ $DAEMON_IP ]] || DAEMON_IP="127.0.0.1" 126 | echo "$DAEMON_IP" 127 | 128 | BBLUE; printf "MONERO RPC PORT | " ;OFF 129 | [[ $DAEMON_RPC ]] || DAEMON_RPC="18081" 130 | echo "$DAEMON_RPC" 131 | 132 | BBLUE; printf "MONERO ZMQ PORT | " ;OFF 133 | [[ $DAEMON_ZMQ ]] || DAEMON_ZMQ="18083" 134 | echo "$DAEMON_ZMQ" 135 | 136 | BBLUE; printf "P2POOL OUT PEERS | " ;OFF 137 | [[ $IN_PEERS ]] || IN_PEERS="10" 138 | echo "$IN_PEERS" 139 | 140 | BBLUE; printf "P2POOL IN PEERS | " ;OFF 141 | [[ $OUT_PEERS ]] || OUT_PEERS="10" 142 | echo "$OUT_PEERS" 143 | 144 | BBLUE; printf "P2POOL LOG LEVEL | " ;OFF 145 | [[ $LOG_LEVEL ]] || LOG_LEVEL="3" 146 | echo "$LOG_LEVEL" 147 | 148 | BBLUE; printf "P2POOL MINI | " ;OFF; echo "$MINI" 149 | 150 | BWHITE; printf "Use these settings? (Y/n) " 151 | 152 | # set user input if yes, repeat if no 153 | Yes() 154 | { 155 | prompt_Sudo ; error_Sudo 156 | safety_HashList 157 | trap "" 1 2 3 6 15 158 | 159 | # p2pool.conf 160 | echo "Editing [p2pool.conf]..." 161 | sudo -u "$USER" sed \ 162 | -i -e "s/^DAEMON_IP=.*$/DAEMON_IP=${DAEMON_IP}/" "$config/p2pool.conf" \ 163 | -i -e "s/^DAEMON_RPC=.*$/DAEMON_RPC=${DAEMON_RPC}/" "$config/p2pool.conf" \ 164 | -i -e "s/^DAEMON_ZMQ=.*$/DAEMON_ZMQ=${DAEMON_ZMQ}/" "$config/p2pool.conf" \ 165 | -i -e "s/^OUT_PEERS=.*$/OUT_PEERS=${OUT_PEERS}/" "$config/p2pool.conf" \ 166 | -i -e "s/^IN_PEERS=.*$/IN_PEERS=${IN_PEERS}/" "$config/p2pool.conf" \ 167 | -i -e "s/^WALLET=.*$/WALLET=${WALLET}/" "$config/p2pool.conf" \ 168 | -i -e "s/^MINI=.*$/MINI=${MINI}/" "$config/p2pool.conf" \ 169 | -i -e "s/^LOG_LEVEL=.*$/LOG_LEVEL=${LOG_LEVEL}/" "$config/p2pool.conf" 170 | 171 | # re-source 172 | parse_Config 173 | 174 | # re-create systemd file 175 | systemd_P2Pool 176 | 177 | # xmrig.json 178 | echo "Editing [xmrig.json]..." 179 | sudo -u "$USER" sed \ 180 | -i -e "s@\"user\":.*@\"user\": \"${WALLET}\",@" "$xmrigConf" \ 181 | -i -e "s@\"url\":.*@\"url\": \"${POOL}\",@" "$xmrigConf" 182 | 183 | # state file 184 | sudo -u "$USER" sed -i "s@.*MINE_UNCONFIGURED.*@MINE_UNCONFIGURED=false@" "$state" 185 | # p2pool mini state 186 | if [[ $MINI = true ]]; then 187 | sudo -u "$USER" echo "MINI_FLAG='--mini'" > "$MB_API/mini" 188 | else 189 | sudo -u "$USER" echo "MINI_FLAG=" > "$MB_API/mini" 190 | fi 191 | PRODUCE_HASH_LIST 192 | echo 193 | BGREEN; echo "Mining configuration complete!" 194 | OFF; echo -n "To get started: " 195 | BWHITE; echo "[monero-bash start all]" 196 | } 197 | No(){ :; } 198 | local yn 199 | read yn 200 | if [[ $yn = "" || $yn = "y" || $yn = "Y" ||$yn = "yes" || $yn = "Yes" ]]; then 201 | Yes 202 | break 203 | else 204 | No 205 | fi 206 | done 207 | } 208 | -------------------------------------------------------------------------------- /src/func/missing.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # Missing "x" Functions 35 | 36 | missing_Template() 37 | { 38 | [[ -e "$DIR" ]] || print_Error_Exit "$THING missing!" 39 | } 40 | 41 | missing_Monero() 42 | { 43 | local DIR="$binMonero/monerod" 44 | local THING="monerod" 45 | missing_Template 46 | } 47 | 48 | missing_MoneroCLI() 49 | { 50 | local DIR="$binMonero/monero-wallet-cli" 51 | local THING="monero-wallet-cli" 52 | missing_Template 53 | } 54 | 55 | missing_BinMonero() 56 | { 57 | local DIR="$binMonero" 58 | local THING="$binMonero" 59 | missing_Template 60 | } 61 | 62 | missing_P2Pool() 63 | { 64 | local DIR="$binP2Pool/p2pool" 65 | local THING="P2Pool" 66 | missing_Template 67 | } 68 | 69 | missing_XMRig() 70 | { 71 | local DIR="$binXMRig/xmrig" 72 | local THING="XMRig" 73 | missing_Template 74 | } 75 | 76 | missing_Wallets() 77 | { 78 | if [[ ! -d "$wallets" ]]; then 79 | print_Warn "$wallets missing!" 80 | echo "Creating wallet folder..." 81 | mkdir "$wallets" 82 | fi 83 | } 84 | 85 | missing_config_Folder() 86 | { 87 | if [[ ! -d "$config" ]]; then 88 | print_Warn "$config missing!" 89 | echo "Creating default config folder..." 90 | build_Config 91 | parse_Config 92 | fi 93 | } 94 | 95 | missing_config_Template() 96 | { 97 | if [[ ! -f "$config/$conf" ]]; then 98 | print_Warn "[${conf}] missing!" 99 | echo "Creating default [${conf}]..." 100 | cp "$installDirectory/config/$conf" "$config/$conf" 101 | parse_Config 102 | fi 103 | } 104 | 105 | missing_config_Monero() 106 | { 107 | local conf="monerod.conf" 108 | missing_config_Template 109 | } 110 | 111 | missing_config_Wallet() 112 | { 113 | local conf="monero-wallet-cli.conf" 114 | missing_config_Template 115 | } 116 | 117 | 118 | missing_config_MoneroBash() 119 | { 120 | local conf="monero-bash.conf" 121 | missing_config_Template 122 | } 123 | 124 | 125 | missing_config_XMRig() 126 | { 127 | local conf="xmrig.json" 128 | missing_config_Template 129 | } 130 | 131 | missing_config_P2Pool() 132 | { 133 | local conf="p2pool.conf" 134 | missing_config_Template 135 | } 136 | 137 | missing_config_All() 138 | { 139 | missing_config_MoneroBash 140 | if [[ $MONERO_VER ]]; then 141 | missing_config_Monero 142 | missing_config_Wallet 143 | fi 144 | [[ $P2POOL_VER ]] && missing_config_P2Pool 145 | [[ $XMRIG_VER ]] && missing_config_XMRig 146 | } 147 | 148 | missing_systemd_Template() 149 | { 150 | # if pkg is installed but no service file: 151 | if [[ $NAME_VER && ! -f $sysd/$SERVICE ]]; then 152 | print_Warn "${SERVICE} missing!" 153 | systemd_"$NAME_FUNC" 154 | fi 155 | } 156 | 157 | missing_systemd_Monero() 158 | { 159 | define_Monero 160 | missing_systemd_Template 161 | } 162 | 163 | missing_systemd_XMRig() 164 | { 165 | define_XMRig 166 | missing_systemd_Template 167 | } 168 | 169 | missing_systemd_P2Pool() 170 | { 171 | define_P2Pool 172 | missing_systemd_Template 173 | } 174 | 175 | missing_systemd_All() 176 | { 177 | missing_systemd_Monero 178 | missing_systemd_XMRig 179 | missing_systemd_P2Pool 180 | } 181 | -------------------------------------------------------------------------------- /src/func/panic.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # panic() 35 | # ------- 36 | # a panic function for when things get bad 37 | # and we really should just exit or loop forever. 38 | # taken from 39 | # modified to add cowsay :) 40 | 41 | panic() { 42 | # get error info 43 | local STD_PANIC_CODE="$?" STD_PANIC_FUNC=("${BASH_LINENO[@]}") STD_PANIC_CMD_NUM=${BASH_LINENO[0]}|| exit 98 44 | # ultra paranoid safety measures (unset bash builtins) 45 | POSIXLY_CORRECT= || exit 11 46 | \unset -f trap set return exit printf echo local unalias unset builtin kill || exit 22 47 | \unalias -a || exit 33 48 | unset POSIXLY_CORRECT || exit 44 49 | unset : || exit 55 50 | printf "\e[7m\e[0;m%s\e[0m\n" "@@@@@@@@ [$0] panic at [${STD_PANIC_CMD_NUM}] @@@@@@@@" 51 | # get command based off line number from $STD_PANIC_CMD_NUM 52 | local STD_PANIC_CMD 53 | mapfile -s $((STD_PANIC_CMD_NUM-1)) -n 1 STD_PANIC_CMD < $0 54 | # print info 55 | printf "\e[1;91m%s\e[0m%s\n" "[code] " "$STD_PANIC_CODE" 56 | printf "\e[1;94m%s\e[0m%s\n" "[ wd ] " "$PWD" 57 | # print function stack 58 | local f 59 | local i=1 60 | STD_PANIC_FUNC=("${STD_PANIC_FUNC[@]:1}") 61 | for f in ${STD_PANIC_FUNC[@]}; do 62 | [[ $f = 0 ]] && break 63 | printf "\e[1;92m%s\e[0m%s\n" "[func] " "${f}: ${FUNCNAME[${i}]}()" 64 | ((i++)) 65 | done 66 | # put trace lines into array, error line in middle, 9 lines total 67 | local STD_PANIC_LINE_ARRAY 68 | local STD_ORIGINAL_LINE="$STD_PANIC_CMD_NUM" 69 | # prevent negative starting line 70 | if [[ $STD_PANIC_CMD_NUM -lt 5 ]]; then 71 | local STD_PANIC_CMD_NUM=1 72 | mapfile -n 9 STD_PANIC_LINE_ARRAY < $0 73 | else 74 | local STD_PANIC_CMD_NUM=$((STD_PANIC_CMD_NUM-4)) 75 | mapfile -s $((STD_PANIC_CMD_NUM-1)) -n 9 STD_PANIC_LINE_ARRAY < $0 76 | fi 77 | # print lines with numbers (with manual spacing) 78 | # the array elements already have newlines, 79 | # so none are added with printf. 80 | for i in {0..8}; do 81 | # if no lines left, break 82 | [[ ${STD_PANIC_LINE_ARRAY[$i]} ]] || break 83 | # if error line, print bold white 84 | if [[ $STD_PANIC_CMD_NUM = "$STD_ORIGINAL_LINE" ]]; then 85 | case ${#STD_PANIC_CMD_NUM} in 86 | 1) printf "\e[1;97m%s" " $STD_PANIC_CMD_NUM ${STD_PANIC_LINE_ARRAY[${i}]}" ;; 87 | 2) printf "\e[1;97m%s" " $STD_PANIC_CMD_NUM ${STD_PANIC_LINE_ARRAY[${i}]}" ;; 88 | 3) printf "\e[1;97m%s" " $STD_PANIC_CMD_NUM ${STD_PANIC_LINE_ARRAY[${i}]}" ;; 89 | 4) printf "\e[1;97m%s" " $STD_PANIC_CMD_NUM ${STD_PANIC_LINE_ARRAY[${i}]}" ;; 90 | 5) printf "\e[1;97m%s" " $STD_PANIC_CMD_NUM ${STD_PANIC_LINE_ARRAY[${i}]}" ;; 91 | *) printf "\e[1;97m%s" "$STD_PANIC_CMD_NUM ${STD_PANIC_LINE_ARRAY[${i}]}" ;; 92 | esac 93 | # else print grey 94 | else 95 | case ${#STD_PANIC_CMD_NUM} in 96 | 1) printf "\e[1;90m%s" " $STD_PANIC_CMD_NUM ${STD_PANIC_LINE_ARRAY[${i}]}" ;; 97 | 2) printf "\e[1;90m%s" " $STD_PANIC_CMD_NUM ${STD_PANIC_LINE_ARRAY[${i}]}" ;; 98 | 3) printf "\e[1;90m%s" " $STD_PANIC_CMD_NUM ${STD_PANIC_LINE_ARRAY[${i}]}" ;; 99 | 4) printf "\e[1;90m%s" " $STD_PANIC_CMD_NUM ${STD_PANIC_LINE_ARRAY[${i}]}" ;; 100 | 5) printf "\e[1;90m%s" " $STD_PANIC_CMD_NUM ${STD_PANIC_LINE_ARRAY[${i}]}" ;; 101 | *) printf "\e[1;90m%s" "$STD_PANIC_CMD_NUM ${STD_PANIC_LINE_ARRAY[${i}]}" ;; 102 | esac 103 | fi 104 | ((STD_PANIC_CMD_NUM++)) 105 | done 106 | # cowsay 107 | printf "${OFF}%s\n" \ 108 | " ________________________________________________________ " \ 109 | "/ You've encountered a fatal error in [monero-bash]! \\ " \ 110 | "| It would be very helpful if you reported this bug with | " \ 111 | "| the information above to the GitHub issues page at: | " 112 | printf "%s${BYELLOW}%s${OFF}%s\n" \ 113 | "\\ " "" " / " 114 | printf "%s\n" \ 115 | " -------------------------------------------------------- " \ 116 | " \ ^__^ " \ 117 | " \ (oo)\_______ " \ 118 | " (__)\ )\\/\\ " \ 119 | " ||----w | " \ 120 | " || || " 121 | [[ $1 =~ ^[0-9]+$ ]] && exit $1 || exit 99 122 | # endless loop 123 | while :; do read -s -r; done 124 | # just in case, kill and exit 125 | printf "\e[0;m%s\n" "@ loop fail, killing \$$ @" 126 | builtin kill -s KILL 0 127 | } 128 | -------------------------------------------------------------------------------- /src/func/parse.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # Parse config files safely. 35 | parse_Config() { 36 | # [monero-bash.conf] 37 | local CONFIG_GREP=$(config::grep "$config/monero-bash.conf" \ 38 | bool AUTO_START_DAEMON \ 39 | bool AUTO_STOP_DAEMON \ 40 | bool AUTO_UPDATE \ 41 | bool PRICE_API_IP_WARNING \ 42 | pos WATCH_REFRESH_RATE \ 43 | bool USE_TOR \ 44 | bool TOR_QUIET \ 45 | port TOR_PROXY \ 46 | bool TEST_TOR \ 47 | bool FAKE_HTTP_HEADERS \ 48 | bool TOR_BROWSER_MIMIC \ 49 | bool ONLY_USER_AGENT \ 50 | bool ONLY_WGET_CURL \ 51 | bool HTTP_HEADERS_VERBOSE \ 52 | port DAEMON_RPC_IP \ 53 | bool DAEMON_RPC_VERBOSE \ 54 | bool AUTO_HUGEPAGES \ 55 | int HUGEPAGES 56 | ) 57 | declare -g $CONFIG_GREP || { printf "\e[1;31m%s\n" "[MONERO BASH FATAL ERROR] monero-bash.conf source failure"; panic; } 58 | 59 | # default for empty values 60 | [[ $AUTO_START_DAEMON ]] || { declare -g AUTO_START_DAEMON=false || panic; } 61 | [[ $AUTO_STOP_DAEMON ]] || { declare -g AUTO_STOP_DAEMON=false || panic; } 62 | [[ $AUTO_UPDATE ]] || { declare -g AUTO_UPDATE=false || panic; } 63 | [[ $PRICE_API_IP_WARNING ]] || { declare -g PRICE_API_IP_WARNING=false || panic; } 64 | [[ $USE_TOR ]] || { declare -g USE_TOR=false || panic; } 65 | [[ $TOR_PROXY ]] || { declare -g TOR_PROXY=127.0.0.1:9050 || panic; } 66 | [[ $TEST_TOR ]] || { declare -g TEST_TOR=false || panic; } 67 | [[ $TOR_QUIET ]] || { declare -g TOR_QUIET=false || panic; } 68 | [[ $FAKE_HTTP_HEADERS ]] || { declare -g FAKE_HTTP_HEADERS=false || panic; } 69 | [[ $TOR_BROWSER_MIMIC ]] || { declare -g TOR_BROWSER_MIMIC=false || panic; } 70 | [[ $ONLY_USER_AGENT ]] || { declare -g ONLY_USER_AGENT=false || panic; } 71 | [[ $ONLY_WGET_CURL ]] || { declare -g ONLY_WGET_CURL=false || panic; } 72 | [[ $HTTP_HEADERS_VERBOSE ]] || { declare -g HTTP_HEADERS_VERBOSE=false || panic; } 73 | [[ $DAEMON_RPC_IP ]] || { declare -g DAEMON_RPC_IP=127.0.0.1:18081 || panic; } 74 | [[ $DAEMON_RPC_VERBOSE ]] || { declare -g DAEMON_RPC_VERBOSE=false || panic; } 75 | [[ $AUTO_HUGEPAGES ]] || { declare -g AUTO_HUGEPAGES=false || panic; } 76 | [[ $HUGEPAGES ]] || { declare -g HUGEPAGES=3072 || panic; } 77 | # range [1-60] 78 | [[ $WATCH_REFRESH_RATE -ge 1 && $WATCH_REFRESH_RATE -le 60 ]] || { declare -g WATCH_REFRESH_RATE=5 || panic; } 79 | # split tor ip/port 80 | [[ $TOR_PROXY ]] && { declare -g TOR_IP=${TOR_PROXY/:*} TOR_PORT=${TOR_PROXY/*:} || panic; } 81 | 82 | # [p2pool.conf] 83 | [[ $P2POOL_VER ]] || return 0 84 | local CONFIG_GREP=$(config::grep "$p2poolConf" \ 85 | char WALLET \ 86 | bool MINI \ 87 | ip DAEMON_IP \ 88 | int DAEMON_RPC \ 89 | int DAEMON_ZMQ \ 90 | pos OUT_PEERS \ 91 | pos IN_PEERS \ 92 | [0-6] LOG_LEVEL 93 | ) 94 | declare -g $CONFIG_GREP || { printf "\e[1;31m%s\n" "[MONERO BASH FATAL ERROR] p2pool.conf source failure"; panic; } 95 | # range [10-450] 96 | if [[ $OUT_PEERS ]]; then 97 | [[ $OUT_PEERS -ge 10 && $OUT_PEERS -le 450 ]] || { declare -g OUT_PEERS=10 || panic; } 98 | fi 99 | if [[ $IN_PEERS ]]; then 100 | [[ $IN_PEERS -ge 10 && $IN_PEERS -le 450 ]] || { declare -g IN_PEERS=10 || panic; } 101 | fi 102 | # default for empty values 103 | # covered by [process.sh] & [systemd.sh] 104 | # (in a really messy way) 105 | } 106 | -------------------------------------------------------------------------------- /src/func/path.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # Path Functions 35 | # manages path installation, removal, etc. 36 | 37 | path_Add() 38 | { 39 | if [[ -f "/usr/local/bin/monero-bash" ]]; then 40 | IRED; echo -n "monero-bash PATH is already set: " 41 | OFF; echo "/usr/local/bin/monero-bash" 42 | path_Reset 43 | else 44 | sudo ln -s "$installDirectory/monero-bash" "/usr/local/bin/monero-bash" 45 | error_Continue "Adding to PATH failed" 46 | fi 47 | } 48 | 49 | path_Remove() 50 | { 51 | if [[ -f "/usr/local/bin/monero-bash" ]]; then 52 | sudo rm "/usr/local/bin/monero-bash" 53 | else 54 | IRED; echo "monero-bash PATH is not set" 55 | fi 56 | } 57 | 58 | path_Reset() 59 | { 60 | echo "Resetting monero-bash PATH..." 61 | sudo rm "/usr/local/bin/monero-bash" 62 | error_Exit "Removing from PATH failed" 63 | sudo ln -s "$installDirectory/monero-bash" "/usr/local/bin/monero-bash" 64 | error_Exit "Adding to PATH failed" 65 | IGREEN; echo "monero-bash PATH reset!" 66 | } 67 | -------------------------------------------------------------------------------- /src/func/permission.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # unix permissions for folders 35 | 36 | permission_DotMoneroBash() 37 | { 38 | sudo chmod 700 "$dotMoneroBash" 39 | sudo chmod -R 600 "$config" 40 | sudo chmod 700 "$config" "$wallets" 41 | sudo chown -R "$USER:$USER" "$dotMoneroBash" 42 | } 43 | 44 | permission_InstallDirectory() 45 | { 46 | sudo chmod -R 700 "$installDirectory" 47 | sudo chmod -R 600 "$installDirectory/config" "$installDirectory/src/txt" "$MB_API" 48 | sudo chmod 700 "$installDirectory/config" "$installDirectory/src/txt" "$MB_API" 49 | sudo chown -R "$USER:$USER" "$installDirectory" 50 | } 51 | 52 | permission_Systemd() 53 | { 54 | [[ -f /etc/systemd/system/monero-bash-monerod.service ]] && sudo chmod 600 /etc/systemd/system/monero-bash-monerod.service 55 | [[ -f /etc/systemd/system/monero-bash-p2pool.service ]] && sudo chmod 600 /etc/systemd/system/monero-bash-p2pool.service 56 | [[ -f /etc/systemd/system/monero-bash-xmrig.service ]] && sudo chmod 600 /etc/systemd/system/monero-bash-xmrig.service 57 | } 58 | 59 | permission_All() 60 | { 61 | permission_InstallDirectory 62 | permission_Systemd 63 | permission_DotMoneroBash 64 | } 65 | -------------------------------------------------------------------------------- /src/func/price.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # fetch price data 35 | 36 | price_Check() 37 | { 38 | [[ $FAKE_HTTP_HEADERS = true ]] && header_Random 39 | [[ $USE_TOR = true ]] && { torsocks_init; echo; } || prompt_PriceAPI_IP 40 | local PRICE LINK="https://min-api.cryptocompare.com/data/pricemultifull?fsyms=XMR&tsyms=USD,EUR,JPY,GBP,CHF,CAD,AUD,ZAR,BTC,ETH,BCH,ZEC,BNB,XRP,ADA,SOL,DOT,DOGE,TRX,ETC,LTC,LINK,XLM,ALGO" 41 | # use TOR if enabled 42 | if [[ $USE_TOR = true ]]; then 43 | if [[ $WGET_GZIP = true ]]; then 44 | PRICE=$(torsocks_func wget -qO- "${WGET_HTTP_HEADERS[@]}" -e robots=off "$LINK" | gzip -d) 45 | code_Wget 46 | else 47 | PRICE=$(torsocks_func wget -qO- "${WGET_HTTP_HEADERS[@]}" -e robots=off "$LINK") 48 | code_Wget 49 | fi 50 | else 51 | if [[ $WGET_GZIP = true ]]; then 52 | PRICE=$(wget -qO- "${WGET_HTTP_HEADERS[@]}" -e robots=off "$LINK" | gzip -d) 53 | code_Wget 54 | else 55 | PRICE=$(wget -qO- "${WGET_HTTP_HEADERS[@]}" -e robots=off "$LINK") 56 | code_Wget 57 | fi 58 | fi 59 | # check for API errors 60 | case "$PRICE" in 61 | *"rate limit"*) 62 | print_Error " API rate-limit error" 63 | [[ $USE_TOR = true ]] && print_Error "Restarting Tor may help: " 64 | exit 1 65 | ;; 66 | ""|" ") 67 | print_Error_Exit "Could not get data from API" 68 | [[ $USE_TOR = true ]] && print_Error "Restarting Tor may help: " 69 | exit 1 70 | ;; 71 | esac 72 | 73 | # declare JSON values into variables 74 | local $(echo "$PRICE" | json::var | grep "RAW.*PRICE\|RAW.*HIGHDAY\|RAW.*LOWDAY\|RAW.*CHANGEPCTDAY\|RAW_XMR_USD_LASTUPDATE\|RAW_XMR_BTC_LASTUPDATE") 75 | # timestamp conversion 76 | RAW_XMR_USD_LASTUPDATE=$(printf "%(%F %T)T" "$RAW_XMR_USD_LASTUPDATE") 77 | RAW_XMR_BTC_LASTUPDATE=$(printf "%(%F %T)T" "$RAW_XMR_BTC_LASTUPDATE") 78 | # fiat 79 | local FIAT=$(\ 80 | printf "%s${BWHITE}${UWHITE}%s${OFF}%s\n" \ 81 | "| " "Fiat Currency | Symbol | Price | Day High | Day Low | Day Change %" " |" 82 | printf "%s\n" \ 83 | "| United States Dollar | USD | ${RAW_XMR_USD_PRICE:0:7} | ${RAW_XMR_USD_HIGHDAY:0:7} | ${RAW_XMR_USD_LOWDAY:0:7} | ${RAW_XMR_USD_CHANGEPCTDAY:0:5}% |" \ 84 | "| Great British Pound | GBP | ${RAW_XMR_GBP_PRICE:0:7} | ${RAW_XMR_GBP_HIGHDAY:0:7} | ${RAW_XMR_GBP_LOWDAY:0:7} | ${RAW_XMR_GBP_CHANGEPCTDAY:0:5}% |" \ 85 | "| European Euro | EUR | ${RAW_XMR_EUR_PRICE:0:7} | ${RAW_XMR_EUR_HIGHDAY:0:7} | ${RAW_XMR_EUR_LOWDAY:0:7} | ${RAW_XMR_EUR_CHANGEPCTDAY:0:5}% |" \ 86 | "| Japanese Yen | JPY | ${RAW_XMR_JPY_PRICE:0:7} | ${RAW_XMR_JPY_HIGHDAY:0:7} | ${RAW_XMR_JPY_LOWDAY:0:7} | ${RAW_XMR_JPY_CHANGEPCTDAY:0:5}% |" \ 87 | "| Swiss Franc | CHF | ${RAW_XMR_CHF_PRICE:0:7} | ${RAW_XMR_CHF_HIGHDAY:0:7} | ${RAW_XMR_CHF_LOWDAY:0:7} | ${RAW_XMR_CHF_CHANGEPCTDAY:0:5}% |" \ 88 | "| Canadian Dollar | CAD | ${RAW_XMR_CAD_PRICE:0:7} | ${RAW_XMR_CAD_HIGHDAY:0:7} | ${RAW_XMR_CAD_LOWDAY:0:7} | ${RAW_XMR_CAD_CHANGEPCTDAY:0:5}% |" \ 89 | "| Australian Dollar | AUD | ${RAW_XMR_AUD_PRICE:0:7} | ${RAW_XMR_AUD_HIGHDAY:0:7} | ${RAW_XMR_AUD_LOWDAY:0:7} | ${RAW_XMR_AUD_CHANGEPCTDAY:0:5}% |" \ 90 | "| South African Rand | ZAR | ${RAW_XMR_ZAR_PRICE:0:7} | ${RAW_XMR_ZAR_HIGHDAY:0:7} | ${RAW_XMR_ZAR_LOWDAY:0:7} | ${RAW_XMR_ZAR_CHANGEPCTDAY:0:5}% |") 91 | # cryptocurrency 92 | local CRYPTO=$(\ 93 | printf "%s${BWHITE}${UWHITE}%s${OFF}%s\n" \ 94 | "| " "Cryptocurrency | Symbol | Price | Day High | Day Low | Day Change %" " |" 95 | printf "%s\n" \ 96 | "| Bitcoin | BTC | ${RAW_XMR_BTC_PRICE:0:7} | ${RAW_XMR_BTC_HIGHDAY:0:7} | ${RAW_XMR_BTC_LOWDAY:0:7} | ${RAW_XMR_BTC_CHANGEPCTDAY:0:5}% |" \ 97 | "| Ethereum | ETH | ${RAW_XMR_ETH_PRICE:0:7} | ${RAW_XMR_ETH_HIGHDAY:0:7} | ${RAW_XMR_ETH_LOWDAY:0:7} | ${RAW_XMR_ETH_CHANGEPCTDAY:0:5}% |" \ 98 | "| BNB | BNB | ${RAW_XMR_BNB_PRICE:0:7} | ${RAW_XMR_BNB_HIGHDAY:0:7} | ${RAW_XMR_BNB_LOWDAY:0:7} | ${RAW_XMR_BNB_CHANGEPCTDAY:0:5}% |" \ 99 | "| Ripple | XRP | ${RAW_XMR_XRP_PRICE:0:7} | ${RAW_XMR_XRP_HIGHDAY:0:7} | ${RAW_XMR_XRP_LOWDAY:0:7} | ${RAW_XMR_XRP_CHANGEPCTDAY:0:5}% |" \ 100 | "| Cardano | ADA | ${RAW_XMR_ADA_PRICE:0:7} | ${RAW_XMR_ADA_HIGHDAY:0:7} | ${RAW_XMR_ADA_LOWDAY:0:7} | ${RAW_XMR_ADA_CHANGEPCTDAY:0:5}% |" \ 101 | "| Solana | SOL | ${RAW_XMR_SOL_PRICE:0:7} | ${RAW_XMR_SOL_HIGHDAY:0:7} | ${RAW_XMR_SOL_LOWDAY:0:7} | ${RAW_XMR_SOL_CHANGEPCTDAY:0:5}% |" \ 102 | "| Polkadot | DOT | ${RAW_XMR_DOT_PRICE:0:7} | ${RAW_XMR_DOT_HIGHDAY:0:7} | ${RAW_XMR_DOT_LOWDAY:0:7} | ${RAW_XMR_DOT_CHANGEPCTDAY:0:5}% |" \ 103 | "| Dogecoin | DOGE | ${RAW_XMR_DOGE_PRICE:0:7} | ${RAW_XMR_DOGE_HIGHDAY:0:7} | ${RAW_XMR_DOGE_LOWDAY:0:7} | ${RAW_XMR_DOGE_CHANGEPCTDAY:0:5}% |" \ 104 | "| TRON | TRX | ${RAW_XMR_TRX_PRICE:0:7} | ${RAW_XMR_TRX_HIGHDAY:0:7} | ${RAW_XMR_TRX_LOWDAY:0:7} | ${RAW_XMR_TRX_CHANGEPCTDAY:0:5}% |" \ 105 | "| Ethereum Classic | ETC | ${RAW_XMR_ETC_PRICE:0:7} | ${RAW_XMR_ETC_HIGHDAY:0:7} | ${RAW_XMR_ETC_LOWDAY:0:7} | ${RAW_XMR_ETC_CHANGEPCTDAY:0:5}% |" \ 106 | "| Litecoin | LTC | ${RAW_XMR_LTC_PRICE:0:7} | ${RAW_XMR_LTC_HIGHDAY:0:7} | ${RAW_XMR_LTC_LOWDAY:0:7} | ${RAW_XMR_LTC_CHANGEPCTDAY:0:5}% |" \ 107 | "| Chainlink | LINK | ${RAW_XMR_LINK_PRICE:0:7} | ${RAW_XMR_LINK_HIGHDAY:0:7} | ${RAW_XMR_LINK_LOWDAY:0:7} | ${RAW_XMR_LINK_CHANGEPCTDAY:0:5}% |" \ 108 | "| Stellar | XLM | ${RAW_XMR_XLM_PRICE:0:7} | ${RAW_XMR_XLM_HIGHDAY:0:7} | ${RAW_XMR_XLM_LOWDAY:0:7} | ${RAW_XMR_XLM_CHANGEPCTDAY:0:5}% |" \ 109 | "| Bitcoin Cash | BCH | ${RAW_XMR_BCH_PRICE:0:7} | ${RAW_XMR_BCH_HIGHDAY:0:7} | ${RAW_XMR_BCH_LOWDAY:0:7} | ${RAW_XMR_BCH_CHANGEPCTDAY:0:5}% |" \ 110 | "| Algorand | ALGO | ${RAW_XMR_ALGO_PRICE:0:7} | ${RAW_XMR_ALGO_HIGHDAY:0:7} | ${RAW_XMR_ALGO_LOWDAY:0:7} | ${RAW_XMR_ALGO_CHANGEPCTDAY:0:5}% |" \ 111 | "| ZCash | ZEC | ${RAW_XMR_ZEC_PRICE:0:7} | ${RAW_XMR_ZEC_HIGHDAY:0:7} | ${RAW_XMR_ZEC_LOWDAY:0:7} | ${RAW_XMR_ZEC_CHANGEPCTDAY:0:5}% |") 112 | # Stupid stupid stupid Ubuntu comes with BSD's [column] 113 | # so [-o] doesn't work. This doesn't even make sense, 114 | # Ubuntu is mostly GNU/util-linux userspace but for certain 115 | # programs it has the BSD versions? I thought this was maybe 116 | # inherited from Debian but even Debian has [util-linux's] version. 117 | # Why why why why why Ubuntu. 118 | 119 | # Instead of specifically testing for [x] distro, 120 | # just test to see if the [column -o] option works. 121 | if echo "Why Ubuntu" | column -o -t &>/dev/null; then 122 | printf "${BRED}%s${OFF}\n" "[XMR <-> Fiat] <$RAW_XMR_USD_LASTUPDATE>" 123 | printf "%s\n" "|-----------------------------------------------------------------------------|" 124 | echo -e "$FIAT" | column -t -s '|' -o '|' 125 | printf "%s\n" "|-----------------------------------------------------------------------------|" 126 | echo 127 | printf "${BRED}%s${OFF}\n" "[XMR <-> Cryptocurrency] <$RAW_XMR_BTC_LASTUPDATE>" 128 | printf "%s\n" "|---------------------------------------------------------------------------|" 129 | echo -e "$CRYPTO" | column -t -s '|' -o '|' 130 | printf "%s\n" "|---------------------------------------------------------------------------|" 131 | else 132 | printf "${BRED}%s${OFF}\n" "[XMR <-> Fiat] <$RAW_XMR_USD_LASTUPDATE>" 133 | echo -e "$FIAT" | column -t -s '|' 134 | echo 135 | printf "${BRED}%s${OFF}\n" "[XMR <-> Cryptocurrency] <$RAW_XMR_BTC_LASTUPDATE>" 136 | echo -e "$CRYPTO" | column -t -s '|' 137 | fi 138 | } 139 | -------------------------------------------------------------------------------- /src/func/prompt.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # Prompt Functions 35 | prompt_YESno() 36 | { 37 | read yn 38 | if [[ $yn = "" || $yn = "y" || $yn = "Y" ||$yn = "yes" || $yn = "Yes" ]]; then 39 | Yes 40 | else 41 | No 42 | fi 43 | } 44 | 45 | prompt_NOyes() 46 | { 47 | read yn 48 | if [[ $yn = "y" || $yn = "Y" ||$yn = "yes" || $yn = "Yes" ]]; then 49 | Yes 50 | elif [[ $yn = "" ]]; then 51 | No 52 | else 53 | No 54 | fi 55 | } 56 | 57 | prompt_Sudo() 58 | { 59 | sudo -v 60 | } 61 | 62 | prompt_PriceAPI_IP() 63 | { 64 | if [[ $PRICE_API_IP_WARNING = "true" ]]; then 65 | OFF; echo -n "Edit " 66 | IRED; echo -n "PRICE_API_IP_WARNING " 67 | OFF; echo -n "in " 68 | IRED; echo -n "monero-bash.conf " 69 | OFF; echo "to silence this warning" 70 | echo 71 | OFF; echo -n "This will expose your IP to: " 72 | IRED; echo "https://cryptocompare.com" 73 | OFF; echo -n "Continue? (y/N) " 74 | Yes(){ :;} 75 | No(){ echo "Exiting..." ;exit 1;} 76 | prompt_NOyes 77 | fi 78 | } 79 | -------------------------------------------------------------------------------- /src/func/remove.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # remove functions 35 | 36 | remove_Template() 37 | { 38 | if [[ "$NAME_VER" = "" ]]; then 39 | OFF; echo -n "$NAME_PRETTY: " 40 | IRED; echo "is not installed" 41 | else 42 | # sudo, trap 43 | prompt_Sudo;error_Sudo 44 | safety_HashList 45 | trap "" 1 2 3 6 15 46 | 47 | # removal 48 | print_RedHash "Removing [$NAME_PRETTY]" 49 | printf "${BWHITE}%s${OFF}\n" "Removing [${DIRECTORY}]" 50 | sudo rm -rf "$DIRECTORY" 51 | printf "${BWHITE}%s${OFF}\n" "Removing [${SERVICE}]" 52 | sudo rm "$sysd/$SERVICE" 53 | 54 | # updating state file 55 | printf "${BWHITE}%s${OFF}\n" "Updating local state" 56 | sudo sed -i "s@.*"$NAME_CAPS"_VER=.*@"$NAME_CAPS"_VER=\"\"@" "$state" 57 | sudo sed -i "s@.*"$NAME_CAPS"_OLD=.*@"$NAME_CAPS"_OLD=\"true\"@" "$state" 58 | PRODUCE_HASH_LIST 59 | printf "${BRED}%s${OFF}\n" "<######> Removed [$NAME_PRETTY]" 60 | fi 61 | } 62 | 63 | remove_Monero() 64 | { 65 | define_Monero 66 | remove_Template 67 | } 68 | 69 | remove_MoneroBash() 70 | { 71 | IWHITE; echo -n "type: " 72 | BRED; echo -n "monero-bash uninstall " 73 | IWHITE; echo "to remove monero-bash" 74 | } 75 | 76 | remove_XMRig() 77 | { 78 | define_XMRig 79 | remove_Template 80 | } 81 | 82 | remove_P2Pool() 83 | { 84 | define_P2Pool 85 | remove_Template 86 | } 87 | 88 | remove_All() 89 | { 90 | remove_Monero 91 | remove_XMRig 92 | remove_P2Pool 93 | } 94 | -------------------------------------------------------------------------------- /src/func/reset.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # for overwriting current (old) configs with new ones from "$installDirectory/config" 35 | # and old systemd services with new ones 36 | 37 | reset_Config() 38 | { 39 | case $NAME_PRETTY in 40 | Monero) RESET_FILE="monerod.conf & monero-wallet-cli.conf";; 41 | monero-bash) RESET_FILE=monero-bash.conf;; 42 | XMRig) RESET_FILE=xmrig.json;; 43 | P2Pool) RESET_FILE=p2pool.conf;; 44 | esac 45 | 46 | # PROMPT 47 | BRED; printf "This will overwrite your current " 48 | BWHITE; echo -n "[$RESET_FILE] " 49 | BRED; echo "with a new default version" 50 | BWHITE; printf "Continue? (y/N) " ;OFF 51 | Yes(){ echo "Resetting..." ;} 52 | No(){ echo "Exiting..." ;exit 1;} 53 | prompt_NOyes 54 | 55 | trap "" 1 2 3 6 15 56 | # OVERWRITE 57 | case $NAME_PRETTY in 58 | Monero) 59 | echo "Resetting [$config/monerod.conf]..." 60 | cp -f "$installDirectory/config/monerod.conf" "$config/monerod.conf" 61 | echo "Resetting [$config/monero-wallet-cli.conf]..." 62 | cp -f "$installDirectory/config/monero-wallet-cli.conf" "$config/monero-wallet-cli.conf" 63 | ;; 64 | monero-bash) 65 | echo "Resetting [$config/monero-bash.conf]..." 66 | cp -f "$installDirectory/config/monero-bash.conf" "$config/monero-bash.conf" 67 | ;; 68 | XMRig) 69 | echo "Resetting [$xmrigConf]..." 70 | cp -f "$installDirectory/config/xmrig.json" "$xmrigConf" 71 | ;; 72 | P2Pool) 73 | echo "Resetting [$config/p2pool.conf]..." 74 | cp -f "$installDirectory/config/p2pool.conf" "$config/p2pool.conf" 75 | ;; 76 | esac 77 | BGREEN; echo "Reset OK"; OFF 78 | } 79 | 80 | reset_Systemd() 81 | { 82 | # PROMPT 83 | BRED; printf "This will overwrite your current " 84 | BWHITE; echo -n "[$NAME_PRETTY] " 85 | BRED; echo "systemd service with a new default version" 86 | BWHITE; printf "Continue? (y/N) " ;OFF 87 | Yes(){ echo "Resetting..." ;} 88 | No(){ echo "Exiting..." ;exit 1;} 89 | prompt_NOyes 90 | 91 | trap "" 1 2 3 6 15 92 | if systemd_${NAME_FUNC}; then 93 | BGREEN; echo "Reset OK"; OFF 94 | else 95 | BRED; echo "Reset FAIL"; OFF 96 | return 1 97 | fi 98 | } 99 | -------------------------------------------------------------------------------- /src/func/rpc.sh: -------------------------------------------------------------------------------- 1 | # Original code taken from: https://github.com/jtgrassie/xmrpc 2 | # Modified slightly to work within monero-bash as a function. 3 | # 4 | # Copyright (c) 2014-2022, The Monero Project 5 | # 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # 1. Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # 2. Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # 3. Neither the name of the copyright holder nor the names of its contributors 19 | # may be used to endorse or promote products derived from this software without 20 | # specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | rpc_Daemon() 34 | { 35 | quote() { 36 | [[ "$1" =~ ^[0-9]+$ ]] && echo -n "$1" && return 37 | [[ "$1" =~ ^true|false$ ]] && echo -n "$1" && return 38 | [[ "${1::1}" == "[" ]] && echo -n "$(parse_arr $1)" && return 39 | echo -n "\"$1\"" 40 | } 41 | 42 | parse_arr() { 43 | let e=${#1}-2 44 | sz=${1:1:$e} 45 | a=(${sz//,/ }) 46 | for i in "${!a[@]}"; do 47 | a[$i]=$(quote ${a[i]}) 48 | done 49 | aj=$(printf ",%s" "${a[@]}") 50 | aj=${aj:1} 51 | echo -n "[${aj}]" 52 | } 53 | 54 | parse_nv() { 55 | nv=(${1//:/ }) 56 | c=${#nv[@]} 57 | [[ $c == 2 ]] && echo -n "$(quote ${nv[0]}):$(quote ${nv[1]})" 58 | } 59 | 60 | if [[ "$1" == *:* ]]; then 61 | DAEMON_RPC_IP="$1/json_rpc" 62 | shift 63 | elif [[ "$1" != *:* && -z "$DAEMON_RPC_IP" ]]; then 64 | DAEMON_RPC_IP="http://localhost:18081/json_rpc" 65 | elif [[ "$1" != *:* && ! -z "$DAEMON_RPC_IP" ]]; then 66 | DAEMON_RPC_IP="${DAEMON_RPC_IP}/json_rpc" 67 | fi 68 | 69 | method="$1" ; shift 70 | payload="{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"$method\"" 71 | if [ -n "$1" ]; then 72 | if [[ "${1::1}" == "[" ]]; then 73 | payload="$payload,\"params\":$(parse_arr $1)" 74 | else 75 | payload="$payload,\"params\":{" 76 | while [ -n "$1" ]; do 77 | payload="${payload}$(parse_nv $1)" 78 | [ -n "$2" ] && payload="$payload," 79 | shift 80 | done 81 | payload="$payload}" 82 | fi 83 | fi 84 | payload="$payload}" 85 | 86 | # Set [Wget/Curl] HTTP header for RPC calls 87 | if [[ $FAKE_HTTP_HEADERS = true && $DAEMON_RPC_IP != localhost* && $DAEMON_RPC_IP != 127.0.0.1* && $DAEMON_RPC_IP != 192.168.* ]]; then 88 | declare -g RPC_CALL=true ONLY_USER_AGENT=true ONLY_WGET_CURL=true 89 | header_Random 90 | fi 91 | 92 | if [[ $USE_TOR = true && $DAEMON_RPC_IP != localhost* && $DAEMON_RPC_IP != 127.0.0.1* && $DAEMON_RPC_IP != 192.168.* ]]; then 93 | torsocks_init 94 | [[ $TOR_QUIET = true ]] || echo 95 | torsocks_func wget \ 96 | -qO- \ 97 | "$DAEMON_RPC_IP" \ 98 | "${WGET_HTTP_HEADERS[@]}" --post-data=$payload 99 | else 100 | wget \ 101 | -qO- \ 102 | "$DAEMON_RPC_IP" \ 103 | "${WGET_HTTP_HEADERS[@]}" --post-data=$payload 104 | fi 105 | if [[ $? != 0 ]]; then 106 | print_Error "Monero RPC connection failed" 107 | exit 1 108 | else 109 | echo 110 | fi 111 | 112 | if [[ $DAEMON_RPC_VERBOSE = true ]]; then 113 | echo 114 | BWHITE; printf "DAEMON_RPC_IP: " ;OFF; echo "$DAEMON_RPC_IP" 115 | BWHITE; printf "PAYLOAD: " ;OFF; echo "$payload" 116 | fi 117 | } 118 | -------------------------------------------------------------------------------- /src/func/safety.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | 35 | # Safety checks so monero-bash doesn't blow something up 36 | 37 | # checks if /.monero-bash/ exists, if not, build default 38 | safety_DotMoneroBash() 39 | { 40 | if [[ ! -d "$dotMoneroBash" ]]; then 41 | print_Warn "[${HOME}/.monero-bash/] folder not found!" 42 | echo "Building default [.monero-bash] folder..." 43 | build_DotMoneroBash 44 | OFF; echo "Built!" 45 | fi 46 | } 47 | 48 | # check if in /usr/local/share/monero-bash 49 | safety_UsrLocalShare() 50 | { 51 | if [[ "$installDirectory" != "/usr/local/share/monero-bash" ]]; then 52 | IRED; echo "ERROR: monero-bash not in /usr/local/share/ !" 53 | OFF; echo "was monero-bash installed properly?" 54 | echo "Exiting for safety..." 55 | exit 1 56 | fi 57 | } 58 | 59 | # checks quiet_hashlist only if not previously checked (used in download) 60 | safety_HashList() 61 | { 62 | if [[ $alreadyCheckedHashList != "true" ]]; then 63 | QUIET_HASH_LIST 64 | alreadyCheckedHashList="true" 65 | echo 66 | fi 67 | } 68 | 69 | safety_Root() 70 | { 71 | if [[ "$EUID" = 0 ]]; then 72 | printf "\033[1;31m[MONERO-BASH ERROR] " 73 | printf "\033[1;37mDO NOT RUN AS ROOT\n" 74 | exit 1 75 | fi 76 | } 77 | 78 | # monero-bash only supports 1 user 79 | safety_User() 80 | { 81 | if [[ "$INSTALLED_USER" != "$USER" ]]; then 82 | printf "\033[1;31m[monero-bash error] " 83 | printf "\033[0mOnly this user is allowed: " 84 | printf "\033[1;37m$INSTALLED_USER\n" 85 | exit 1 86 | fi 87 | } 88 | 89 | # check for GNU/Linux 90 | safety::gnu_linux() { 91 | if [[ $OSTYPE != *linux-gnu* ]]; then 92 | printf "\033[1;31m%s\033[0m%s\n%s\n" \ 93 | "[monero-bash error] " \ 94 | "GNU/Linux not detected!" \ 95 | "Exiting for safety..." 96 | exit 1 97 | fi 98 | } 99 | 100 | 101 | # check for bash v5+ 102 | safety::bash() { 103 | if [[ ! ${BASH_VERSINFO[0]} -ge 5 ]]; then 104 | printf "\033[1;31m%s\033[0m%s\n%s\n" \ 105 | "[monero-bash error] " \ 106 | "Your Bash is older than v5." \ 107 | "Exiting for safety..." 108 | exit 1 109 | fi 110 | } 111 | 112 | # check for x86_64bit 113 | # only invoked during the initial [monero-bash] install 114 | safety::x86_64() { 115 | [[ $(uname -m) = x86_64 ]] || print_Error_Exit "Non-x86_64 computer detected, refusing to continue" 116 | } 117 | 118 | # check for sane environment 119 | # variables and set as readonly. 120 | safety::env() { 121 | # $HOME 122 | case "$HOME" in 123 | "/home/$USER") :;; 124 | *) print_Error_Exit "Dangerous \$HOME variable detected, refusing to start";; 125 | esac 126 | # $USER 127 | case "$USER" in 128 | "${HOME/\/home\/}") :;; 129 | *) print_Error_Exit "Dangerous \$USER variable detected, refusing to start";; 130 | esac 131 | # $PATH 132 | case "$PATH" in 133 | */usr/bin*) :;; 134 | */bin*) :;; 135 | *) print_Error_Exit "Dangerous \$PATH variable detected, refusing to start";; 136 | esac 137 | # Path isn't declared as READONLY because 138 | # it needs to be edited when using Tor 139 | # (getcap is in /usr/sbin which isn't in PATH for Debian) 140 | # 141 | # USER also gets edited to root for XMRig, so no readonly 142 | declare -gxr HOME 143 | } 144 | -------------------------------------------------------------------------------- /src/func/tmp.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | 35 | # functions for creating /tmp/ folders 36 | 37 | tmp_Create() 38 | { 39 | tmp_Del 40 | mktemp -d /tmp/monero-bash.XXXXXXXXXX &>/dev/null 41 | tmp="$(find /tmp/monero-bash.*)" 42 | mktemp -d /tmp/monero-bash-hash.XXXXXXXXXX &>/dev/null 43 | mktemp /tmp/monero-bash-gpg.XXXXXXXXXX &>/dev/null 44 | tmpHash="$(find /tmp/monero-bash-hash.*)" 45 | tmpGPG="$(find /tmp/monero-bash-gpg.*)" 46 | if [[ $downloadXMRig = "true" ]]; then 47 | mktemp -d /tmp/monero-bash-sig.XXXXXXXXXX &>/dev/null 48 | tmpSig="$(find /tmp/monero-bash-sig.*)" 49 | fi 50 | } 51 | 52 | tmp_Del() 53 | { 54 | if find /tmp/monero-bash* &>/dev/null ; then 55 | rm -rf /tmp/monero-bash* 56 | fi 57 | } 58 | -------------------------------------------------------------------------------- /src/func/trap.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | 35 | # trap that handles exits (and cleanup) 36 | trap_Template() 37 | { 38 | trap "" 1 2 3 6 15 || panic 39 | [[ $VERBOSE = "true" ]]&& verbose_Upgrade 40 | } 41 | 42 | # continue current operation until finished and revert (ONLY FOR UPGRADE) 43 | trap_No() 44 | { 45 | trap_Template 46 | trapSet="true" 47 | error_Trap "LETTING DATA TRANSFER FINISH TO PREVENT CORRUPTION" 48 | exit 49 | } 50 | 51 | # does everything POST install (rm temp files, state, hash) 52 | trap_Post() 53 | { 54 | trap_Template 55 | error_Trap "WRITING TO STATE BEFORE EXITING" 56 | version_Template 57 | sudo -u "$USER" sed -i "s@.*"$NAME_CAPS"_VER=.*@"$NAME_CAPS"_VER=\""$NewVer"\"@" "$state" 58 | sudo -u "$USER" sed -i "s@.*"$NAME_CAPS"_OLD=.*@"$NAME_CAPS"_OLD=\"false\"@" "$state" 59 | case $NAME_PRETTY in 60 | monero-bash|P2Pool) 61 | [[ $NAME_PRETTY = monero-bash ]] && local CONFIG_FILE=monero-bash.conf 62 | [[ $NAME_PRETTY = P2Pool ]] && local CONFIG_FILE=p2pool.conf 63 | CONFIG_OLD=$(<"$config/$CONFIG_FILE") 64 | CONFIG_MERGE=$(config::merge "$config/$CONFIG_FILE" "$installDirectory/config/$CONFIG_FILE") 65 | if [[ $CONFIG_OLD = "$CONFIG_MERGE" ]]; then 66 | echo "[$CONFIG_FILE] No updates detected" 67 | elif [[ $CONFIG_MERGE ]]; then 68 | echo "[$CONFIG_FILE] Merging old+new" 69 | echo "$CONFIG_MERGE" > "$config/$CONFIG_FILE" 70 | else 71 | print_Warn "Merging old+new [$CONFIG_FILE] failed" 72 | fi 73 | esac 74 | [[ "$INSTALL" = "true" ]]&& systemd_"$NAME_FUNC" 75 | PRODUCE_HASH_LIST 76 | sudo chown -R $USER "$installDirectory" 77 | [[ -d "$old" ]]&& sudo rm -rf "$old" 78 | tmp_Del 79 | exit 80 | } 81 | 82 | # delete tmp folder 83 | trap_Tmp() 84 | { 85 | trap_Template 86 | error_Trap "CLEANING TEMP FILES" 87 | tmp_Del 88 | exit 89 | } 90 | 91 | # revert monero-bash upgrades 92 | trap_MoneroBash() 93 | { 94 | trap_Template 95 | error_Trap "RESTORING OLD MONERO-BASH" 96 | sudo -u "$USER" mv -f "$old/monero-bash" "$installDirectory" 97 | sudo -u "$USER" mv -fr "$old/src" "$installDirectory" 98 | sudo -u "$USER" mv -fr "$old/config" "$installDirectory" 99 | sudo -u "$USER" mv -fr "$old/gpg" "$installDirectory" 100 | sudo -u "$USER" mv -f "$old/src/txt/state" "$state" 101 | sudo -u "$USER" cp -fr "$old/src/mini" "$installDirectory/src/" 102 | tmp_Del 103 | exit 104 | } 105 | 106 | # delete old folder 107 | trap_Old() 108 | { 109 | trap_Template 110 | error_Trap "CLEANING OLD FOLDER" 111 | [[ -d "$old" ]]&& rm -rf "$old" 112 | tmp_Del 113 | exit 114 | } 115 | 116 | # recreate hash list 117 | trap_Hash() 118 | { 119 | trap_Template 120 | error_Trap "RE-PRODUCING HASHLIST" 121 | PRODUCE_HASH_LIST 122 | exit 123 | } 124 | 125 | # turn off mining prompt 126 | trap_Mining() { 127 | trap_Template 128 | error_Trap "WRITING TO STATE" 129 | sudo -u "$USER" sed -i "s@.*MINE_UNCONFIGURED.*@MINE_UNCONFIGURED=false@" "$state" 130 | PRODUCE_HASH_LIST 131 | } 132 | -------------------------------------------------------------------------------- /src/func/update.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | 35 | # update functions 36 | 37 | update_Template() 38 | { 39 | version_Update 40 | if [[ "$NAME_VER" != "$NewVer" ]]; then 41 | BWHITE; echo -n "$NAME_SPACED" 42 | BRED; echo -n "$NAME_VER " 43 | BWHITE; echo -n "-> " 44 | BGREEN; echo "$NewVer" 45 | updateFound="true" 46 | sudo sed -i "s@.*"$NAME_CAPS"_OLD=.*@"$NAME_CAPS"_OLD=\"true\"@" "$state" || panic 47 | PRODUCE_HASH_LIST &>/dev/null 48 | else 49 | sudo sed -i "s@.*"$NAME_CAPS"_OLD=.*@"$NAME_CAPS"_OLD=\"false\"@" "$state" || panic 50 | PRODUCE_HASH_LIST &>/dev/null 51 | BWHITE; echo -n "$NAME_SPACED" 52 | BGREEN; echo "$NAME_VER" 53 | fi 54 | } 55 | 56 | update_Monero() 57 | { 58 | define_Monero 59 | local NAME_SPACED="Monero | " 60 | update_Template 61 | } 62 | 63 | update_MoneroBash() 64 | { 65 | define_MoneroBash 66 | local NAME_SPACED="monero-bash | " 67 | update_Template 68 | } 69 | 70 | update_XMRig() 71 | { 72 | define_XMRig 73 | local NAME_SPACED="XMRig | " 74 | update_Template 75 | } 76 | 77 | update_P2Pool() 78 | { 79 | define_P2Pool 80 | local NAME_SPACED="P2Pool | " 81 | update_Template 82 | } 83 | 84 | update_All() 85 | { 86 | prompt_Sudo 87 | error_Sudo 88 | [[ $FAKE_HTTP_HEADERS = true ]] && header_Random 89 | [[ $USE_TOR = true ]] && torsocks_init && echo 90 | printf "${BBLUE}${UBLUE}%s\n${OFF}" "<###> Fetching package metadata <###>" 91 | update_MoneroBash 92 | [[ $MONERO_VER != "" ]]&& update_Monero 93 | [[ $XMRIG_VER != "" ]]&& update_XMRig 94 | [[ $P2POOL_VER != "" ]]&& update_P2Pool 95 | if [[ $updateFound = "true" ]]; then 96 | echo 97 | OFF; echo -n "Updates found, type: " 98 | BYELLOW; echo -n "[monero-bash upgrade] " 99 | OFF; echo "to upgrade all" 100 | OFF 101 | return 0 102 | else 103 | printf "\n${BGREEN}%s${OFF}\n" "<####> All packages up-to-date <####>" 104 | return 1 105 | fi 106 | } 107 | -------------------------------------------------------------------------------- /src/func/verbose.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | 35 | # echo all the variable definitions 36 | # after upgrading 37 | # 38 | verbose_Upgrade() 39 | { 40 | printf "${BYELLOW}%s${OFF}%s\n" \ 41 | "NAME_VER | " "$NAME_VER" \ 42 | "NAME_OLD | " "$NAME_OLD" \ 43 | "NAME_PRETTY | " "$NAME_PRETTY" \ 44 | "NAME_FUNC | " "$NAME_FUNC" \ 45 | "NAME_CAPS | " "$NAME_CAPS" \ 46 | "SERVICE | " "$SERVICE" \ 47 | "DIRECTORY | " "$DIRECTORY" \ 48 | "API | " "$API" \ 49 | "HTML | " "$HTML" \ 50 | "AUTHOR | " "$AUTHOR" \ 51 | "PROJECT | " "$PROJECT" \ 52 | "STAR_PKG | " "$STAR_PKG" \ 53 | "DOT_PKG | " "$DOT_PKG" \ 54 | "SHA | " "$SHA" \ 55 | "SIG | " "$SIG" \ 56 | "FINGERPRINT | " "$FINGERPRINT" \ 57 | "VERIFY_GPG | " "$VERIFY_GPG" \ 58 | "NewVer | " "$NewVer" \ 59 | "LINK | " "$LINK" \ 60 | "GPG_PUB_KEY | " "$GPG_PUB_KEY" \ 61 | "hashLink | " "$hashLink" \ 62 | "sigLink | " "$sigLink" \ 63 | "tmp | " "$tmp" \ 64 | "tmpHash | " "$tmpHash" \ 65 | "tmpSig | " "$tmpSig" \ 66 | "hashFile | " "$hashFile" \ 67 | "sigFile | " "$sigFile" \ 68 | "folderName | " "$folderName" \ 69 | "tarFile | " "$tarFile" \ 70 | "HASH | " "$HASH" \ 71 | "LOCAL_HASH | " "$LOCAL_HASH" 72 | local IFS=$'\n' 73 | for i in $hashSTDOUT; do 74 | printf "${BPURPLE}%s${OFF}%s\n" "hashSTDOUT | " "$i" 75 | done 76 | for i in $gpgSTDOUT; do 77 | printf "${BBLUE}%s${OFF}%s\n" "gpgSTDOUT | " "$i" 78 | done 79 | } 80 | -------------------------------------------------------------------------------- /src/func/verify.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | 35 | # hash & GPG verification of binaries 36 | # 37 | # everyone has a slightly differently named sha256sum 38 | # file, with slightly different internal formatting 39 | # which makes this function a bit long. 40 | # 41 | # the order of operations is the same as the "download_Template" function 42 | # but instead it's downloading the SHA256SUM file and 43 | # filtering it to find the proper hash to compare against 44 | 45 | verify_Template() 46 | { 47 | # api or html? (or are we downloading monero?) 48 | if [[ $HTML = true && $downloadMonero != true ]]; then 49 | hashLink="$(echo "$DUMP" \ 50 | | grep -o "/$AUTHOR/$PROJECT/releases/download/.*/$SHA" \ 51 | | head -n1 \ 52 | | awk '{print $1}' \ 53 | | tr -d '"' \ 54 | | sed 's@^@https://github.com@')" 55 | elif [[ $API = true && $downloadMonero != true ]]; then 56 | hashLink="$(echo "$DUMP" \ 57 | | json::var \ 58 | | grep -om1 "browser_download_url.*${SHA}")" 59 | hashLink="${hashLink/*=}" 60 | else 61 | hashLink="https://www.getmonero.org/downloads/hashes.txt" 62 | fi 63 | 64 | # setting of the tmp file variables (and gpg) 65 | tarFile="$(ls "$tmp")" 66 | if [[ $USE_TOR = true ]]; then 67 | torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -q -P "$tmpHash" "$hashLink" 68 | else 69 | wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -q -P "$tmpHash" "$hashLink" 70 | fi 71 | code_Wget 72 | hashFile="$(ls "$tmpHash")" 73 | sigFile="$hashFile" 74 | if [[ $WGET_GZIP = true ]]; then 75 | mv "$tmpHash/$hashFile" "$tmpHash/${hashFile}.gz" && gzip -d "$tmpHash/$hashFile" &>/dev/null || mv "$tmpHash/${hashFile}.gz" "$tmpHash/$hashFile" 76 | fi 77 | hashSTDOUT="$(<"$tmpHash/$hashFile")" 78 | 79 | # check if gpg key is imported 80 | if ! gpg --list-keys "$FINGERPRINT" &>/dev/null ;then 81 | OFF; echo "Importing [${GPG_OWNER}]'s PGP key..." 82 | gpg_import_Template 83 | fi 84 | 85 | # xmrig author pls include the sig in the hash file 86 | if [[ $downloadXMRig = true ]]; then 87 | if [[ $HTML = true ]]; then 88 | sigLink="$(echo "$DUMP" \ 89 | | grep -o "/$AUTHOR/$PROJECT/releases/download/.*/$SIG" \ 90 | | head -n1 \ 91 | | awk '{print $1}' \ 92 | | tr -d '"' \ 93 | | sed 's@^@https://github.com@')" 94 | elif [[ $API = true ]]; then 95 | sigLink="$(echo "$DUMP" \ 96 | | json::var \ 97 | | grep -om1 "browser_download_url.*${SIG}")" 98 | sigLink="${sigLink/*=}" 99 | fi 100 | if [[ $USE_TOR = true ]]; then 101 | torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -q -P "$tmpSig" "$sigLink" 102 | else 103 | wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -q -P "$tmpSig" "$sigLink" 104 | fi 105 | code_Wget 106 | sigFile="$(ls "$tmpSig")" 107 | if [[ $WGET_ZIP = true ]]; then 108 | mv "$tmpSig/$sigFile" "$tmpSig/${sigFile}.gz" && gzip -d "$tmpSig/$sigFile" &>/dev/null || mv "$tmpSig/${sigFile}.gz" "$tmpSig/$sigFile" 109 | fi 110 | fi 111 | 112 | # comparison of hashes (and are we downloading p2pool?) 113 | if [[ $downloadP2Pool = "true" ]]; then 114 | HASH="$(echo "$hashSTDOUT" | grep -A2 "$DOT_PKG" | grep "SHA256" | awk '{print $2}')" 115 | else 116 | HASH="$(echo "$hashSTDOUT" | grep "$DOT_PKG" | awk '{print $1}')" 117 | fi 118 | [[ -z $HASH ]] && error_Exit "Hash file was empty" 119 | echo "$HASH" "$tmp/$tarFile" | sha256sum -c &>/dev/null 120 | print_OKFAILED 121 | if [[ $verifyOK != true ]]; then 122 | LOCAL_HASH="$(sha256sum "$tmp/$tarFile" | awk '{print $1}' | tr -d " -")" 123 | compromised_Hash 124 | fi 125 | 126 | # gpg check 127 | if [[ $downloadXMRig = true ]]; then 128 | gpg --verify "$tmpSig/$sigFile" "$tmpHash/$hashFile" &> "$tmpGPG" 129 | print_GPG 130 | else 131 | gpg --verify "$tmpHash/$sigFile" &> "$tmpGPG" 132 | print_GPG 133 | fi 134 | gpgSTDOUT="$( 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | 35 | # order of operations: 36 | # 1. filter $DUMP variable (from "download_Template" function) 37 | # 2. find the proper version number 38 | # 3. save it as $NewVer variable 39 | 40 | # invoked by upgrade_Template() function, reuses 41 | # the $DUMP variable set in download_Template() 42 | version_Template() 43 | { 44 | if [[ $HTML = true ]]; then 45 | NewVer="$(echo "$DUMP" \ 46 | | grep -o "/$AUTHOR/$PROJECT/releases/tag/.*\"" \ 47 | | awk '{print $1}' | head -n1 \ 48 | | sed "s@/$AUTHOR/$PROJECT/releases/tag/@@g" | tr -d '"')" 49 | [[ $NewVer ]] || error_Exit "GitHub HTML filter failed..." 50 | else 51 | NewVer="$(echo "$DUMP" | json::var | grep "tag_name")" 52 | NewVer=${NewVer/*=} 53 | fi 54 | [[ $NewVer != v* ]] && print_Error_Exit "[${NewVer}] Weird version found, exiting for safety..." 55 | } 56 | 57 | # invoked by "monero-bash update" 58 | version_Update() 59 | { 60 | if [[ $USE_TOR = true ]]; then 61 | if [[ $WGET_GZIP = true ]]; then 62 | LINK="$(torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- "https://api.github.com/repos/$AUTHOR/$PROJECT/releases/latest" | gzip -d)" 63 | else 64 | LINK="$(torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- "https://api.github.com/repos/$AUTHOR/$PROJECT/releases/latest")" 65 | fi 66 | else 67 | if [[ $WGET_GZIP = true ]]; then 68 | LINK="$(wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- "https://api.github.com/repos/$AUTHOR/$PROJECT/releases/latest" | gzip -d)" 69 | else 70 | LINK="$(wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- "https://api.github.com/repos/$AUTHOR/$PROJECT/releases/latest")" 71 | fi 72 | fi 73 | if [[ $? != 0 && $HTML != true ]]; then 74 | IRED; echo "GitHub API error detected..." 75 | OFF; echo "Trying GitHub HTML filter instead..." 76 | HTML="true" 77 | fi 78 | if [[ $HTML = true ]]; then 79 | if [[ $USE_TOR = true ]]; then 80 | if [[ $WGET_GZIP = true ]]; then 81 | NewVer="$(torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- https://github.com/$AUTHOR/$PROJECT/releases/latest | gzip -d)" 82 | else 83 | NewVer="$(torsocks_func wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- https://github.com/$AUTHOR/$PROJECT/releases/latest)" 84 | fi 85 | else 86 | if [[ $WGET_GZIP = true ]]; then 87 | NewVer="$(wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- https://github.com/$AUTHOR/$PROJECT/releases/latest | gzip -d)" 88 | else 89 | NewVer="$(wget "${WGET_HTTP_HEADERS[@]}" -e robots=off -qO- https://github.com/$AUTHOR/$PROJECT/releases/latest)" 90 | fi 91 | fi 92 | NewVer=$(echo "$NewVer" \ 93 | | grep -o "/$AUTHOR/$PROJECT/releases/tag/.*\"" \ 94 | | awk '{print $1}' | head -n1 \ 95 | | sed "s@/$AUTHOR/$PROJECT/releases/tag/@@g" | tr -d '"') 96 | [[ $NewVer ]] || error_Exit "GitHub HTML filter failed..." 97 | else 98 | NewVer="$(echo "$LINK" | json::var | grep "tag_name")" 99 | NewVer=${NewVer/*=} 100 | fi 101 | [[ $NewVer != v* ]] && print_Error_Exit "[${NewVer}] Weird version found, exiting for safety..." 102 | } 103 | 104 | -------------------------------------------------------------------------------- /src/func/wallet.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | 35 | # Monero Wallet Functions 36 | 37 | wallet_Start() 38 | { 39 | # CHECK IF MISSING BINARY 40 | missing_MoneroCLI 41 | 42 | # AUTO MONEROD START 43 | [[ $AUTO_START_DAEMON = "true" ]]&& define_Monero&&process_Start 44 | 45 | # CD INTO .monero-bash SO FILES/LOGS GET CREATED THERE 46 | cd "$dotMoneroBash" 47 | 48 | # START NORMALLY 49 | "$binMonero/monero-wallet-cli" \ 50 | --wallet-file "$wallets/$walletSelection" \ 51 | --password "$walletPassword" \ 52 | --config-file "$config/monero-wallet-cli.conf" 53 | error_Exit "Could not start monero-wallet-cli" 54 | 55 | # AUTO MONEROD STOP 56 | [[ $AUTO_STOP_DAEMON = "true" ]]&& define_Monero&&process_Stop 57 | exit 0 58 | } 59 | 60 | # this much better wallet::create() function was 61 | # stolen from [monero-bash v2.0.0] and slightly 62 | # modified to work with the crusty old code 63 | # that is [monero-bash v1.x.x] :D 64 | # it allows for creation of all wallet types. 65 | wallet::create() { 66 | # CHECK IF MISSING BINARY 67 | missing_MoneroCLI 68 | 69 | # CD INTO .monero-bash SO FILES/LOGS GET CREATED THERE 70 | cd "$dotMoneroBash" 71 | 72 | # WALLET TYPES 73 | while :; do 74 | while :; do 75 | echo 76 | printf "${BPURPLE}%s${OFF}%s${BRED}%s${OFF}\n" \ 77 | "--generate-new-wallet " "| " "[new]" \ 78 | "--generate-from-view-key " "| " "[view]" \ 79 | "--restore-from-seed " "| " "[seed]" \ 80 | "--generate-from-json " "| " "[json]" \ 81 | "--generate-from-spend-key " "| " "[spend]" \ 82 | "--generate-from-device " "| " "[device]" \ 83 | "--generate-from-keys " "| " "[private]" \ 84 | "--generate-from-multisig-keys " "| " "[multisig]" \ 85 | "" 86 | printf "${BWHITE}%s${OFF}" "Which wallet type? " 87 | 88 | read -r WALLET_TYPE 89 | case "$WALLET_TYPE" in 90 | --generate-new-wallet|*new*) WALLET_TYPE=new;break;; 91 | --generate-from-view-key|*view*) WALLET_TYPE=view;break;; 92 | --restore-from-seed|*seed*) WALLET_TYPE=seed;break;; 93 | --generate-from-json|*json*) WALLET_TYPE=json;break;; 94 | --generate-from-spend-key|*spend*) WALLET_TYPE=spend;break;; 95 | --generate-from-device|*device*) WALLET_TYPE=device;break;; 96 | --generate-from-keys|*private*) WALLET_TYPE=private;break;; 97 | --generate-from-multisig-keys|*multi*) WALLET_TYPE=multisig;break;; 98 | exit|Exit|EXIT) exit 0;; 99 | 'exit()') printf "%s\n" "This isn't Python but ok >_>"; exit 0;; 100 | 'exit(0);') printf "%s\n" "This isn't C but ok >_>"; exit 0;; 101 | *) print_Error "Invalid wallet type!" 102 | esac 103 | done 104 | printf "${BWHITE}%s${BRED}%s${BWHITE}%s${OFF}" \ 105 | "Create wallet type " \ 106 | "[${WALLET_TYPE}]" \ 107 | "? (Y/n) " 108 | read yn 109 | case $yn in 110 | y|Y|yes|Yes|YES|""|" ") break;; 111 | *) :;; 112 | esac 113 | done 114 | 115 | # Wallet name 116 | while :; do 117 | if [[ $WALLET_TYPE = json ]]; then 118 | printf "${BWHITE}%s${OFF}" "JSON file path: " 119 | read -r WALLET_NAME 120 | case "$WALLET_NAME" in 121 | "") print_Error "Empty input";; 122 | *) printf "\n${BPURPLE}%s${BWHITE}%s${OFF}\n" "Using file " "[$WALLET_NAME]"; break;; 123 | esac 124 | else 125 | printf "${BWHITE}%s${OFF}" "Wallet name: " 126 | read -r WALLET_NAME 127 | case "$WALLET_NAME" in 128 | "") print_Error "Empty input";; 129 | *" "*) print_Error "Wallet name cannot have spaces";; 130 | *) printf "\n${BPURPLE}%s${BWHITE}%s${OFF}\n" "Creating wallet " "[$WALLET_NAME]"; break;; 131 | esac 132 | fi 133 | done 134 | 135 | # Case wallet type 136 | if case "$WALLET_TYPE" in 137 | new) 138 | "$binMonero/monero-wallet-cli" \ 139 | --generate-new-wallet "$wallets/$WALLET_NAME" \ 140 | --config-file "$config/monero-wallet-cli.conf" 141 | ;; 142 | view) 143 | "$binMonero/monero-wallet-cli" \ 144 | --generate-from-view-key "$wallets/$WALLET_NAME" \ 145 | --config-file "$config/monero-wallet-cli.conf" 146 | ;; 147 | seed) 148 | "$binMonero/monero-wallet-cli" \ 149 | --generate-new-wallet "$wallets/$WALLET_NAME" \ 150 | --config-file "$config/monero-wallet-cli.conf" \ 151 | --restore-from-seed 152 | ;; 153 | json) 154 | "$binMonero/monero-wallet-cli" \ 155 | --generate-from-json "$WALLET_NAME" \ 156 | --config-file "$config/monero-wallet-cli.conf" 157 | ;; 158 | spend) 159 | "$binMonero/monero-wallet-cli" \ 160 | --generate-from-spend-key "$wallets/$WALLET_NAME" \ 161 | --config-file "$config/monero-wallet-cli.conf" 162 | ;; 163 | device) 164 | "$binMonero/monero-wallet-cli" \ 165 | --generate-from-device "$wallets/$WALLET_NAME" \ 166 | --config-file "$config/monero-wallet-cli.conf" 167 | ;; 168 | private) 169 | "$binMonero/monero-wallet-cli" \ 170 | --generate-from-keys "$wallets/$WALLET_NAME" \ 171 | --config-file "$config/monero-wallet-cli.conf" 172 | ;; 173 | multisig) 174 | "$binMonero/monero-wallet-cli" \ 175 | --generate-from-multisig-keys "$wallets/$WALLET_NAME" \ 176 | --config-file "$config/monero-wallet-cli.conf" 177 | ;; 178 | esac; then 179 | exit 0 180 | else 181 | print_Error "monero-wallet-cli error has occurred" 182 | exit 1 183 | fi 184 | } 185 | 186 | wallet_Count() 187 | { 188 | walletCount="$(ls "$wallets" | grep ".keys" | wc -l)" 189 | BYELLOW; echo -n "$walletCount " ;BWHITE 190 | if [[ $walletCount = 1 ]]; then 191 | echo "wallet found:" 192 | echo 193 | elif [[ $walletCount -gt 1 ]]; then 194 | echo "wallets found: " 195 | echo 196 | elif [[ $walletCount = 0 ]]; then 197 | echo "wallets found" 198 | fi 199 | } 200 | 201 | wallet_List() 202 | { 203 | walletList=($(ls "$wallets" | grep ".keys" | sed "s/\.keys//g")) 204 | wallet_list_pretty() 205 | { 206 | local walletAmount=0 207 | local walletChar=0 208 | for i in ${walletList[*]}; do 209 | # wrap line after wallet names 210 | # are > 4 or if exceeds 40 211 | walletAmount=$((walletAmount + 1)) 212 | walletChar=$((walletChar + ${#i} + 4)) #+4 accounts for '[] ' 213 | if [[ $walletAmount -gt 4 || $walletChar -ge 40 ]]; then 214 | walletAmount=0 215 | walletChar=0 216 | printf "${OFF}[${BWHITE}%s${OFF}] \n\n" "${i}" 217 | else 218 | printf "${OFF}[${BWHITE}%s${OFF}] " "${i}" 219 | fi 220 | done 221 | } 222 | # print nice spacing regardless if wallets exist or not 223 | [[ $walletList ]] && echo "$(wallet_list_pretty)" 224 | echo 225 | } 226 | -------------------------------------------------------------------------------- /src/func/warning.sh: -------------------------------------------------------------------------------- 1 | # This file is part of [monero-bash] 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | 35 | # Small warning messages 36 | 37 | warning::watch_refresh_rate() { 38 | if [[ $WATCH_REFRESH_RATE -gt 60 || $WATCH_REFRESH_RATE = 0 ]]; then 39 | print_Warn "[\$WATCH_REFRESH_RATE] has an invalid value! Falling back to [1]" 40 | declare -g WATCH_REFRESH_RATE=1 41 | fi 42 | } 43 | -------------------------------------------------------------------------------- /src/libtorsocks.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hinto-janai/monero-bash/fd72798c181b64394dcd51fcb93a2c1524e5b6ec/src/libtorsocks.so -------------------------------------------------------------------------------- /src/source.sh: -------------------------------------------------------------------------------- 1 | # This file is part of monero-bash - a wrapper for Monero, written in Bash 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # MASTER SOURCE FILE 35 | 36 | # global variables 37 | source "$installDirectory/src/var.sh" &>/dev/null || varMissing="true" 38 | 39 | # global functions 40 | for functions in $installDirectory/src/func/*.sh; do 41 | source "$functions" &>/dev/null || funcMissing="true" 42 | done 43 | 44 | # debug file 45 | source "$installDirectory/src/debug.sh" &>/dev/null || debugMissing="true" 46 | 47 | # state file 48 | source "$installDirectory/src/txt/state" &>/dev/null || stateMissing="true" 49 | 50 | # hashlist file 51 | if [[ ! -f "$installDirectory/src/txt/hashlist" ]]; then 52 | hashlistMissing="true" 53 | fi 54 | -------------------------------------------------------------------------------- /src/txt/hashlist: -------------------------------------------------------------------------------- 1 | 61d42cc206ad0021a95923be9e4e303c73a0c68be121b5c6af335a28205987ec monero-bash 2 | 3f2fbaa499d7f1808748e604a75e1f8bdc2b5c462b03cc912f51280250bf14a8 src/debug.sh 3 | 91464358f1358e3dfbf3968fad81a4fff95d6f3ce0961a1ba1ae7054b6998159 src/libtorsocks.so 4 | 7541df1f9fbb0874f04d2d6f853592ed1b4e91c1d6b0907e12d628bc61430069 src/README.md 5 | 1568574a4a1964c5555c88d07ada6dec993e0d3e30216e30eb06c207c6c0c4bf src/source.sh 6 | b8c39bd2192a4a532c4fde4ee245f6603286e40fae94116c9ec9d6d3245fd670 src/var.sh 7 | fcffb351a45df3362a830205a6de16ae09164cf11aa1d19f0b541d54f64fb723 src/func/backup.sh 8 | 09cc3db9273210edb62f3c754ce2b1ba48e5f7ab2eb5767f90d5678d0d5391e8 src/func/build.sh 9 | c4bd103a710cb09059e0b3bdd0eb178905c8844fa6c1b18fd3e94f956bb081a5 src/func/code.sh 10 | 1d8b7292ad0a9bc395120a9d347e3a50ae11d32531a8ee61c9db08d5a1ac1271 src/func/compromised.sh 11 | cb785dcd3b1c453ed763a47cb1465d62358cd2624f3021002e75dd5a7ba32809 src/func/define.sh 12 | a5e947d71bbd5ba4bc0cdbe557de532c4603baffd4d22ac4a8d106b7a34aba33 src/func/download.sh 13 | b348f5851c9a4bba1171ba79943f316af563dc7f1bfd530ac938e901e35447e2 src/func/edit.sh 14 | 2d6207b438fd8eea76204c426b4a6226d1e6db04a6c4b935d62ac6e47726a6d6 src/func/eol.sh 15 | f8385e2d097bdbac672577bbf2c3c40f982707ae6a7071e2439e4fd27407187c src/func/error.sh 16 | e777ae5d00e09d8fe9e99de0196ace9e9761a423c893e4b41b746e4054f41189 src/func/gpg.sh 17 | 5dc0993c50a246d02ea7974da98487598b7ecd75c1f1b67455f3aabdfcadca2c src/func/header.sh 18 | 6600ad6e8f3e92dd1d5e62e3010560663b96b9ad9d07881bd726b6cb0d3beed4 src/func/install.sh 19 | 23950e07597712b6210f7b19233e0df8476da23e0c88119779843542b743f80c src/func/libconfig.sh 20 | 3768d9abc2f4f20563421ecaa1eaf1902561033a74954f41da64ec56ee6690c9 src/func/libjson.sh 21 | d2d1478135f59883fc5fc6ba0c4c45c4a507912e4443a571a790c8a89a9fa17b src/func/log.sh 22 | c667881a28b35e97297242fe9ea098387dfa8ee655904e2d0c9dad2cf5b300cd src/func/mine.sh 23 | 38f19c3cbf6d9ab37dd4c5b72abfecdc2a35cdc317e9f8c25cf2f5eeca44a255 src/func/missing.sh 24 | f25d85a545a9f78231567cf0681591a940087d777d9ec39ad9c6472e7f90a9d5 src/func/monerobash.sh 25 | a63de1d1559c0daf1232a7e44e586f2f86bf01b8d53e1821ba907f072029fd74 src/func/panic.sh 26 | 004978e004e960e09c3ccbab12f56e8ff247382ebd8ec3dc91c505b5022ea630 src/func/parse.sh 27 | 8c04c4d3337a672b61b222f20fd5b42d4d0164035d9b18ca80252c482f47db2f src/func/path.sh 28 | f71519885b214912e1bd5f5ea19d255e3e5274e0315de6ab8022a7f21d5702fd src/func/permission.sh 29 | 7de4e889c54c421249ff24b77aa3d775970c01d9345ff5b605c86a9e92499476 src/func/price.sh 30 | 28fdd679a0f94d652c563c0906a51aaf615ba15ae2b1f123a3f1136f3f18c183 src/func/print.sh 31 | c6c6f1a522bc6a61fc9183582267aa455020e66febcf10f011a98dfde31546b2 src/func/process.sh 32 | 45c2eea525510d1c7b64f3c86b1efefb793c81a36730b6a8a64dd52906e91737 src/func/prompt.sh 33 | 8a64ecfe00dc9ce5e4a0ac818c8085ca6d4cde4e9c6776ed22759358a22e9504 src/func/remove.sh 34 | 42620bd67a90804832873bcca66a80a8593dfc66afb1cd236c235c9a8794cac6 src/func/reset.sh 35 | 864cd2ca1e5384be52136aae40fc1be0d14a8c7def49b9e19863ec41e460d84e src/func/rpc.sh 36 | 4ac923c4fed9c9884a39a21bd017b27c55018394d979ea7a4964397eeb5b4c31 src/func/safety.sh 37 | 4a41d2f17d080d61e7a400fb0d5bde6be9db725e50dc3d441230eb2e1209d578 src/func/seed.sh 38 | d3e0af11d6752e0d0055026761472ac4137d5ac200e3769099992d76362ca507 src/func/status.sh 39 | b7ac40b997e9ff0f505f3bc9d9d7f03d87a8aeb0bf884096f496921dc07878c6 src/func/systemd.sh 40 | 4817fa80673bc0f39441f059fd753296ef423be91e3dd3b20b37c2e0fa5bfbd7 src/func/tmp.sh 41 | 4d45b12fac198689da3b91c2df08c3a340bfaa5dbea903df3551457813da93d2 src/func/torsocks.sh 42 | b7c44f614290fa0f945c04a3425b6a92a5a16f5c821d5af27e945636d9b3d765 src/func/trap.sh 43 | 467cf9c885ff831a53f86d7f9ba08b699bb7c04ce2c9db7f0af50f1164ee0a49 src/func/update.sh 44 | 6645bc090f7ee265be51f5e9ec4efe20040917a7441581df9b5657f4d64edf41 src/func/upgrade.sh 45 | 459800cbf92fbc6d5693803fca218e440e6bd440f9008c6fee47f9d629c24a03 src/func/verbose.sh 46 | 3988e9081ac7acb9c15411bf44ec245d4f6308fd1f5a09b50b56c3207555575c src/func/verify.sh 47 | 24155b08b4cd0f1908beaf70b1ad2c1713a39d1602c46bcbd11134cc241b5866 src/func/version.sh 48 | 73ab64c4254ccac1bda3e62ca480a2597855ff93ef6bfc2c221355419792ca64 src/func/wallet.sh 49 | 0d79e23f7d13a61a1281bbf09842ef0555d0b24950cac0f9ce73a17a92696010 src/func/warning.sh 50 | 04de74c033179c8fed827505a0648b6b1f34264467b522969728db06acb9e1bb src/func/watch.sh 51 | a7545f1b619fd4f29fb93b1174185563d2c3f2f9211275d5fb3713bd6c26cf48 src/txt/state 52 | 76420d35987f3d577dad9bd13f6598f783d82a3d680210294bacdad8eda05fd8 src/txt/usage 53 | 91775bdd4464ee121adc133326d40d96b931f60ec382a8bc26c60feef5fce508 config/monero-bash.conf 54 | b0863e2c3b46c41b3a0e82998a23292867ff58750e4b9841fd140209475bd08c config/monerod.conf 55 | 04b337c47f50ed5164e4d699c6f39bcb45f7c7c51bf9be80cd8b5904ef102443 config/monero-wallet-cli.conf 56 | 67b30e63fd6f894f3a4edccbf78927658297598d9e7269b359612bfa1dcd4c1b config/p2pool.conf 57 | 8c9ab22bcf574102abe84fa91eff3476c2881a20b73ee61d1ad31316611a279c config/xmrig.json 58 | 7dcb19c87d41a4399b4877054111f7dbfd30531545678bc2be218bd56903904c gpg/binaryfate.asc 59 | 02242a2c4b4dfb2f49d30a15630a301c72910e6e5c212d432c8b7ff438696b00 gpg/hinto-janai.asc 60 | 97de35d05168c8296bbb568b9b79e25fa900857970ae4feb380232230b1515ef gpg/hinto-janaiyo.asc 61 | bb8a4398bc2a18de7d56ffab5f2191f0bbc5860a5fb761d40085f58dafbfd2dd gpg/SChernykh.asc 62 | 5d7bcb7873a2f1a6bfc391b76677ce291ad843da71453dece8634c436e47c9b6 gpg/xmrig.asc 63 | -------------------------------------------------------------------------------- /src/txt/state: -------------------------------------------------------------------------------- 1 | # the file monero-bash uses to read/write state data 2 | 3 | # first time check 4 | FIRST_TIME=true 5 | MINE_UNCONFIGURED=true 6 | 7 | # versions 8 | MONERO_VER= 9 | MONERO_BASH_VER=v1.9.8 10 | XMRIG_VER= 11 | P2POOL_VER= 12 | 13 | # old state 14 | MONERO_OLD=true 15 | MONERO_BASH_OLD=false 16 | XMRIG_OLD=true 17 | P2POOL_OLD=true 18 | 19 | # user 20 | INSTALLED_USER= 21 | -------------------------------------------------------------------------------- /src/txt/usage: -------------------------------------------------------------------------------- 1 | monero-bash Open wallet menu 2 | uninstall Uninstall ALL OF monero-bash 3 | 4 | update Check for package updates 5 | upgrade [force|verbose] Upgrade all out-of-date packages 6 | upgrade [force|verbose] Upgrade a specific package 7 | install [verbose] Install or a specific package 8 | remove Remove or a specific package 9 | 10 | config Configure P2Pool+XMRig mining settings 11 | full Start the process directly attached (foreground) 12 | start Start process with systemd (background) 13 | stop Gracefully stop the systemd process 14 | restart Restart the systemd process 15 | enable Enable the process to auto-start on boot 16 | disable Disable the process from auto-starting on boot 17 | reset [config|systemd] Reset your configs/systemd to default 18 | edit [config|systemd] Edit config/systemd service file 19 | status [monero|p2pool|xmrig] Print status of all installed packages 20 | watch [monero|p2pool|xmrig] Watch live status or a specific process 21 | 22 | tor Test Tor connection 23 | rpc [help] Send a RPC call to monerod 24 | seed [language] Generate random 25-word Monero seed 25 | list List wallets 26 | size Show size of monero-bash folders 27 | price Fetch price data from cryptocompare.com API 28 | version Print versions of installed packages 29 | 30 | backup Encrypt & backup [wallets] -> [backup.tar.gpg] 31 | decrypt Decrypt [backup.tar.gpg] -> [backup] 32 | 33 | help Show this help message 34 | -------------------------------------------------------------------------------- /src/var.sh: -------------------------------------------------------------------------------- 1 | # This file is part of monero-bash - a wrapper for Monero, written in Bash 2 | # 3 | # Copyright (c) 2022 hinto.janaiyo 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | # 23 | # Parts of this project are originally: 24 | # Copyright (c) 2019-2022, jtgrassie 25 | # Copyright (c) 2014-2022, The Monero Project 26 | # Copyright (c) 2011-2022, Dominic Tarr 27 | # 28 | # Parts of this project are licensed under GPLv2: 29 | # Copyright (c) ????-2022, Tamas Szerb 30 | # Copyright (c) 2008-2022, Robert Hogan 31 | # Copyright (c) 2008-2022, David Goulet 32 | # Copyright (c) 2008-2022, Alex Xu (Hello71) 33 | 34 | # 35 | # Global Variables 36 | # 37 | # file/folder paths 38 | usrLocalShare="/usr/local/share" 39 | dotMoneroBash="$HOME/.monero-bash" 40 | config="$dotMoneroBash/config" 41 | wallets="$dotMoneroBash/wallets" 42 | bitMonero="$HOME/.bitmonero" 43 | old="$installDirectory/old" 44 | bin="$installDirectory/bin" 45 | binMonero="$bin/monero" 46 | binXMRig="$bin/xmrig" 47 | binP2Pool="$bin/p2pool" 48 | hashlist="$installDirectory/src/txt/hashlist" 49 | state="$installDirectory/src/txt/state" 50 | sysd="/etc/systemd/system" 51 | xmrigConf="$config/xmrig.json" 52 | p2poolConf="$config/p2pool.conf" 53 | p2poolApi="$binP2Pool/local/stats" 54 | MB_API="$installDirectory/src/api" 55 | 56 | # 57 | # Colors 58 | # 59 | # regular 60 | BLACK() { printf "\e[0;30m"; } 61 | RED() { printf "\e[0;31m"; } 62 | GREEN() { printf "\e[0;32m"; } 63 | YELLOW() { printf "\e[0;33m"; } 64 | BLUE() { printf "\e[0;34m"; } 65 | PURPLE() { printf "\e[0;35m"; } 66 | CYAN() { printf "\e[0;36m"; } 67 | WHITE() { printf "\e[0;37m"; } 68 | # BOLD 69 | BBLACK() { printf "\e[1;90m"; } 70 | BRED() { printf "\e[1;91m"; } 71 | BGREEN() { printf "\e[1;92m"; } 72 | BYELLOW() { printf "\e[1;93m"; } 73 | BBLUE() { printf "\e[1;94m"; } 74 | BPURPLE() { printf "\e[1;95m"; } 75 | BCYAN() { printf "\e[1;96m"; } 76 | BWHITE() { printf "\e[1;97m"; } 77 | # UNDERSCORE 78 | UBLACK() { printf "\e[4;30m"; } 79 | URED() { printf "\e[4;31m"; } 80 | UGREEN() { printf "\e[4;32m"; } 81 | UYELLOW() { printf "\e[4;33m"; } 82 | UBLUE() { printf "\e[4;34m"; } 83 | UPURPLE() { printf "\e[4;35m"; } 84 | UCYAN() { printf "\e[4;36m"; } 85 | UWHITE() { printf "\e[4;37m"; } 86 | # HIGH INTENSITY 87 | IBLACK() { printf "\e[0;90m"; } 88 | IRED() { printf "\e[0;91m"; } 89 | IGREEN() { printf "\e[0;92m"; } 90 | IYELLOW() { printf "\e[0;93m"; } 91 | IBLUE() { printf "\e[0;94m"; } 92 | IPURPLE() { printf "\e[0;95m"; } 93 | ICYAN() { printf "\e[0;96m"; } 94 | IWHITE() { printf "\e[0;97m"; } 95 | # NO COLOR 96 | OFF() { printf "\e[0m"; } 97 | 98 | readonly BLACK="\e[0;30m" RED="\e[0;31m" GREEN="\e[0;32m" YELLOW="\e[0;33m" BLUE="\e[0;34m" PURPLE="\e[0;35m" CYAN="\e[0;36m" WHITE="\e[0;37m" BBLACK="\e[1;90m" BRED="\e[1;91m" BGREEN="\e[1;92m" BYELLOW="\e[1;93m" BBLUE="\e[1;94m" BPURPLE="\e[1;95m" BCYAN="\e[1;96m" BWHITE="\e[1;97m" UBLACK="\e[4;30m" URED="\e[4;31m" UGREEN="\e[4;32m" UYELLOW="\e[4;33m" UBLUE="\e[4;34m" UPURPLE="\e[4;35m" UCYAN="\e[4;36m" UWHITE="\e[4;37m" IBLACK="\e[0;90m" IRED="\e[0;91m" IGREEN="\e[0;92m" IYELLOW="\e[0;93m" IBLUE="\e[0;94m" IPURPLE="\e[0;95m" ICYAN="\e[0;96m" IWHITE="\e[0;97m" BOLD="\e[1m" ITALIC="\e[3m" OFF="\e[0m" 99 | -------------------------------------------------------------------------------- /systemd/README.md: -------------------------------------------------------------------------------- 1 | # [monero-bash systemd services] 2 | 3 | The [[systemd] files created by [monero-bash]](https://github.com/hinto-janai/monero-bash/blob/main/src/func/systemd.sh) are created dynamically at the moment of package installation (or when using `monero-bash reset systemd`), based off the user's config file and system. The files here are just the reference for what a typical service should look like. 4 | 5 | -------------------------------------------------------------------------------- /systemd/monero-bash-monerod.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=monero-bash-monerod.service 3 | After=network-online.target 4 | StartLimitIntervalSec=300 5 | StartLimitBurst=5 6 | 7 | [Service] 8 | ## Basics 9 | User=$USER 10 | Group=$USER 11 | Type=simple 12 | 13 | ## Environment 14 | #EnvironmentFile= #none 15 | #EnvironmentFile= #none 16 | 17 | ## Command 18 | ExecStart=/usr/local/share/monero-bash/bin/monero/monerod --config-file /home/$USER/.monero-bash/config/monerod.conf --non-interactive 19 | WorkingDirectory=/usr/local/share/monero-bash/bin/monero 20 | 21 | ## Restart 22 | Restart=on-failure 23 | RestartSec=5s 24 | 25 | ## Open file limit 26 | LimitNOFILE=16384 27 | 28 | ## Wait 35 seconds before sending SIGTERM 29 | KillSignal=SIGTERM 30 | TimeoutStopSec=35s 31 | SendSIGKILL=true 32 | 33 | ## Security Hardening 34 | ## If this service isn't working well (low hashrate, can't connect) 35 | ## you might want to disable some (or all) of the settings below: 36 | CapabilityBoundingSet=~CAP_NET_ADMIN CAP_SYS_PTRACE CAP_SYS_ADMIN CAP_KILL CAP_SYS_PACCT CAP_SYS_BOOT CAP_SYS_CHROOT CAP_LEASE CAP_MKNOD CAP_CHOWN CAP_FSETID CAP_SETFCAP CAP_SETUID CAP_SETGID CAP_SETPCAP CAP_SYS_TIME CAP_IPC_LOCK CAP_LINUX_IMMUTABLE CAP_FOWNER CAP_IPC_OWNER CAP_SYS_RESOURCE CAP_SYS_NICE 37 | ProtectProc=invisible 38 | PrProcSubset=pid 39 | ProtectControlGroups=true 40 | ProtectHostname=true 41 | ProtectClock=true 42 | ProtectKernelModules=true 43 | ProtectKernelLogs=true 44 | ProtectKernelTunables=true 45 | RestrictRealtime=true 46 | RestrictNamespaces=true 47 | PrivateUsers=true 48 | ## These ones shouldn't affect performance and 49 | ## probably should be left on for security reasons. 50 | NoNewPrivileges=true 51 | PrivateTmp=true 52 | ProtectSystem=strict 53 | ProtectHome=read-only 54 | BindPaths=/usr/local/share/monero-bash/bin/monero /home/$USER/.bitmonero 55 | 56 | [Install] 57 | WantedBy=multi-user.target 58 | -------------------------------------------------------------------------------- /systemd/monero-bash-p2pool.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=monero-bash-p2pool.service 3 | After=network-online.target 4 | StartLimitIntervalSec=300 5 | StartLimitBurst=5 6 | 7 | [Service] 8 | ## Basics 9 | User=$USER 10 | Group=$USER 11 | Type=simple 12 | 13 | ## Environment 14 | EnvironmentFile=/home/$USER/.monero-bash/config/p2pool.conf 15 | EnvironmentFile=/usr/local/share/monero-bash/src/api/mini 16 | 17 | ## Command 18 | ExecStart=/usr/local/share/monero-bash/bin/p2pool/p2pool --data-api /usr/local/share/monero-bash/bin/p2pool --stratum-api --host $DAEMON_IP --wallet $WALLET --loglevel $LOG_LEVEL $MINI_FLAG --rpc-port $DAEMON_RPC --zmq-port $DAEMON_ZMQ --out-peers $OUT_PEERS --in-peers $IN_PEERS 19 | WorkingDirectory=/usr/local/share/monero-bash/bin/p2pool 20 | 21 | ## Restart 22 | Restart=on-failure 23 | RestartSec=5s 24 | 25 | ## Open file limit 26 | LimitNOFILE=16384 27 | 28 | ## Wait 35 seconds before sending SIGTERM 29 | KillSignal=SIGTERM 30 | TimeoutStopSec=35s 31 | SendSIGKILL=true 32 | 33 | ## Security Hardening 34 | ## If this service isn't working well (low hashrate, can't connect) 35 | ## you might want to disable some (or all) of the settings below: 36 | CapabilityBoundingSet=~CAP_NET_ADMIN CAP_SYS_PTRACE CAP_SYS_ADMIN CAP_KILL CAP_SYS_PACCT CAP_SYS_BOOT CAP_SYS_CHROOT CAP_LEASE CAP_MKNOD CAP_CHOWN CAP_FSETID CAP_SETFCAP CAP_SETUID CAP_SETGID CAP_SETPCAP CAP_SYS_TIME CAP_IPC_LOCK CAP_LINUX_IMMUTABLE CAP_FOWNER CAP_IPC_OWNER CAP_SYS_RESOURCE CAP_SYS_NICE 37 | ProtectProc=invisible 38 | ProcSubset=pid 39 | ProtectControlGroups=true 40 | ProtectHostname=true 41 | ProtectClock=true 42 | ProtectKernelModules=true 43 | ProtectKernelLogs=true 44 | ProtectKernelTunables=true 45 | RestrictRealtime=true 46 | RestrictNamespaces=true 47 | PrivateUsers=true 48 | ## These ones shouldn't affect performance and 49 | ## probably should be left on for security reasons. 50 | NoNewPrivileges=true 51 | PrivateTmp=true 52 | ProtectSystem=strict 53 | ProtectHome=read-only 54 | BindPaths=/usr/local/share/monero-bash/bin/p2pool 55 | 56 | [Install] 57 | WantedBy=multi-user.target 58 | -------------------------------------------------------------------------------- /systemd/monero-bash-xmrig.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=monero-bash-xmrig.service 3 | After=network-online.target 4 | StartLimitIntervalSec=300 5 | StartLimitBurst=5 6 | 7 | [Service] 8 | ## Basics 9 | User=root 10 | Group=root 11 | Type=simple 12 | 13 | ## Environment 14 | #EnvironmentFile= #none 15 | #EnvironmentFile= #none 16 | 17 | ## Command 18 | ExecStart=/usr/local/share/monero-bash/bin/xmrig/xmrig --config /home/$USER/.monero-bash/config/xmrig.json --log-file=/usr/local/share/monero-bash/bin/xmrig/xmrig-log 19 | WorkingDirectory=/usr/local/share/monero-bash/bin/xmrig 20 | 21 | ## Restart 22 | Restart=on-failure 23 | RestartSec=5s 24 | 25 | ## Open file limit 26 | #LimitNOFILE=4096 #Disabled for XMRig 27 | 28 | ## Wait 35 seconds before sending SIGTERM 29 | KillSignal=SIGTERM 30 | TimeoutStopSec=35s 31 | SendSIGKILL=true 32 | 33 | ## Security Hardening 34 | ## If this service isn't working well (low hashrate, can't connect) 35 | ## you might want to disable some (or all) of the settings below: 36 | CapabilityBoundingSet=~CAP_NET_ADMIN CAP_SYS_PTRACE CAP_SYS_ADMIN CAP_KILL CAP_SYS_PACCT CAP_SYS_BOOT CAP_SYS_CHROOT CAP_LEASE CAP_MKNOD CAP_CHOWN CAP_FSETID CAP_SETFCAP CAP_SETUID CAP_SETGID CAP_SETPCAP CAP_SYS_TIME CAP_IPC_LOCK CAP_LINUX_IMMUTABLE CAP_FOWNER CAP_IPC_OWNER CAP_SYS_RESOURCE CAP_SYS_NICE 37 | ProtectProc=invisible 38 | ProcSubset=pid 39 | ProtectControlGroups=true 40 | #RestrictRealtime=true #Disabled for XMRig 41 | #RestrictNamespaces=true #Disabled for XMRig 42 | #ProtectHostname=true #Disabled for XMRig 43 | #ProtectClock=true #Disabled for XMRig 44 | #ProtectKernelModules=true #Disabled for XMRig 45 | #ProtectKernelLogs=true #Disabled for XMRig 46 | #ProtectKernelTunables=true #Disabled for XMRig 47 | #PrivateUsers=true #Disabled for XMRig 48 | ## These ones shouldn't affect performance and 49 | ## probably should be left on for security reasons. 50 | NoNewPrivileges=true 51 | PrivateTmp=true 52 | ProtectSystem=strict 53 | ProtectHome=read-only 54 | BindPaths=/usr/local/share/monero-bash/bin/xmrig /home/$USER/.monero-bash/config/xmrig.json 55 | 56 | [Install] 57 | WantedBy=multi-user.target 58 | -------------------------------------------------------------------------------- /tests/install_all: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # install all packages verbosely 4 | 5 | install() 6 | { 7 | printf "\n" | monero-bash install all verbose 8 | } 9 | install 10 | -------------------------------------------------------------------------------- /tests/install_all_HTML: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # turns github link into "asdf" which 4 | # forces HTML filter instead of API 5 | 6 | sed -i 's@api.github.com@asdf@' /usr/local/share/monero-bash/src/func/download 7 | monero-bash DEBUG_04e3be9 PRODUCE_HASH_LIST 8 | install() 9 | { 10 | printf "\n" | monero-bash install all verbose 11 | } 12 | install 13 | -------------------------------------------------------------------------------- /utils/aliases: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # aliases to make things quicker 4 | # (source in bashrc) 5 | alias de="monero-bash DEBUG_04e3be9" 6 | alias hl="monero-bash DEBUG_04e3be9 PRODUCE_HASH_LIST" 7 | alias hlc="monero-bash DEBUG_04e3be9 CHECK_HASH_LIST" 8 | 9 | alias t="/tmp/monero-bash_04e3be9/tests/tmp_install" 10 | alias ti="/tmp/monero-bash_04e3be9/tests/tmp_install ; /usr/local/share/monero-bash/tests/install_all" 11 | alias tih="/tmp/monero-bash_04e3be9/tests/tmp_install ; /usr/local/share/monero-bash/tests/install_all_HTML" 12 | alias dev="/tmp/monero-bash_04e3be9/tests/dev_upgrade" 13 | -------------------------------------------------------------------------------- /utils/hash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # re-create hashfile 4 | set -ex 5 | sudo -v 6 | 7 | ./monero-bash DEBUG_04e3be9 PRODUCE_HASH_LIST 8 | ./monero-bash DEBUG_04e3be9 QUIET_HASH_LIST 9 | git add . 10 | git commit -m '!!' 11 | -------------------------------------------------------------------------------- /utils/prepare: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # prepare new [monero-bash] version in: 4 | # 1. README.md 5 | # 2. CHANGELOG.md 6 | # 3. src/txt/state 7 | 8 | # $1 = new_version 9 | set -ex 10 | sudo -v 11 | [[ $1 = v* ]] 12 | 13 | # check dir 14 | if [[ $PWD = */monero-bash ]]; then 15 | : 16 | elif [[ $PWD = */monero-bash/utils ]]; then 17 | cd .. 18 | else 19 | echo "wrong dir" 20 | exit 1 21 | fi 22 | 23 | # get old MONERO_BASH_VER 24 | source src/txt/state 25 | 26 | # sed change 27 | sed -i "s/$MONERO_BASH_VER/$1/g" README.md 28 | sed -i "s/MONERO_BASH_VER=$MONERO_BASH_VER/MONERO_BASH_VER=$1/g" src/txt/state 29 | 30 | # changelog 31 | cat << EOM > CHANGELOG.md.new 32 | # $1 33 | ## Updates 34 | * 35 | 36 | ## Fixes 37 | * 38 | 39 | --- 40 | 41 | EOM 42 | cat CHANGELOG.md >> CHANGELOG.md.new 43 | mv -f CHANGELOG.md.new CHANGELOG.md 44 | 45 | # hash + git commit 46 | ./monero-bash DEBUG_04e3be9 PRODUCE_HASH_LIST 47 | ./monero-bash DEBUG_04e3be9 QUIET_HASH_LIST 48 | git add . 49 | git commit -m "prepare $1" 50 | -------------------------------------------------------------------------------- /utils/release: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # script to create new monero-bash releases 4 | set -e 5 | sudo -v 6 | 7 | # check path 8 | case $PWD in 9 | */monero-bash) :;; 10 | */monero-bash/utils) cd ..;; 11 | *) echo "wrong path"; exit 1;; 12 | esac 13 | 14 | # git folder 15 | path="$HOME/git/monero-bash" 16 | 17 | # create hashlist 18 | if ! ./monero-bash DEBUG_04e3be9 CHECK_HASH_LIST; then 19 | ./monero-bash DEBUG_04e3be9 PRODUCE_HASH_LIST 20 | git add . 21 | git commit -m '!!' 22 | git rebase -i HEAD~1 && git push -f 23 | fi 24 | 25 | # copy to tmp 26 | [[ -d /tmp/monero-bash ]] && rm -fr "/tmp/monero-bash" 27 | cp -fr "$path" "/tmp/" 28 | 29 | # remove non-release files 30 | cd "/tmp/monero-bash" 31 | rm -rf docs .git tests .gitignore LICENSE README.md external lib LICENSE utils 32 | mv -f CHANGELOG.md /tmp/CHANGELOG.md 33 | 34 | # version 35 | source "$path/src/txt/state" 36 | v="monero-bash-${MONERO_BASH_VER}.tar" 37 | 38 | # clean 39 | cd "/tmp" 40 | [[ -e "$v" ]]&& rm "$v" 41 | [[ -e SHA256SUM ]]&& rm SHA256SUM 42 | [[ -e SHA256SUM.asc ]]&& rm SHA256SUM.asc 43 | 44 | # tar 45 | rand=$((EPOCHSECONDS-RANDOM*4)) 46 | date=$(date -d @${rand}) 47 | tar -cpf "$v" "monero-bash" --owner=hinto --group=hinto --mtime="$date" 48 | rm -rf monero-bash 49 | 50 | # hash + sign 51 | sha256sum "$v" > SHA256SUM 52 | gpg --local-user "21958EE945980282FCB849C8D7483F6CA27D1B1D" --clearsign --faked-system-time=${rand} SHA256SUM 53 | rm SHA256SUM 54 | mv SHA256SUM.asc SHA256SUM 55 | 56 | # check hash + sign 57 | gpg --verify SHA256SUM &>/dev/null && echo "sign OK" || echo "sign FAIL" 58 | sha256sum -c SHA256SUM &>/dev/null && echo "hash OK" || echo "hash FAIL" 59 | 60 | # copy changelog/sign to clipboard 61 | CLIP() { 62 | grep -B999 -m1 "^---$" CHANGELOG.md | sed '/^# v1.*$/d; /^---$/d' 63 | echo "## SHA256SUM & [PGP Signature](https://github.com/hinto-janai/monero-bash/blob/main/gpg/hinto-janai.asc)" 64 | echo '```' 65 | cat SHA256SUM 66 | echo '```' 67 | } 68 | CLIP | xclip -selection clipboard 69 | echo "changelog copied to clipboard" 70 | rm CHANGELOG.md 71 | -------------------------------------------------------------------------------- /utils/tmp_install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # 1. install/pull testing branch into /tmp/ 4 | # 2. remove old copies 5 | # 3. copy /tmp/monero-bash_04e3be9 into new folder 6 | # 4. install that copy 7 | # 5. enable gpg 8 | 9 | # 1 10 | if [[ -d /tmp/monero-bash_04e3be9 ]]; then 11 | cd /tmp/monero-bash_04e3be9 12 | git checkout dev 13 | git pull -f 14 | else 15 | cd /tmp 16 | git clone https://github.com/hinto-janai/monero-bash 17 | mv monero-bash monero-bash_04e3be9 18 | fi 19 | 20 | # 2 21 | sudo rm -r /usr/local/share/monero-bash 22 | sudo rm /usr/local/bin/monero-bash 23 | sudo rm -r ~/.monero-bash 24 | sudo rm -r /tmp/monero-bash 25 | sudo rm /etc/systemd/system/monero-bash-*.service 26 | 27 | # 3/4 28 | sudo cp -r /tmp/monero-bash_04e3be9 /tmp/monero-bash 29 | printf "\n\n\n" | /tmp/monero-bash/monero-bash 30 | sudo cp -r /tmp/monero-bash_04e3be9/tests /usr/local/share/monero-bash/ 31 | 32 | # 5 33 | printf "y\n" | monero-bash gpg 34 | -------------------------------------------------------------------------------- /utils/upgrade: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # for installing dev branch of monero-bash 3 | 4 | if [[ $1 ]]; then 5 | BRANCH=$1 6 | echo "[$1] branch selected" 7 | else 8 | BRANCH=dev 9 | echo "defaulting to [dev] branch" 10 | fi 11 | 12 | installDirectory="/usr/local/share/monero-bash" 13 | source $installDirectory/src/source.sh || source $installDirectory/src/source.sh 14 | 15 | # to bypass the v1.x.x EOL message 16 | NewVer=v1.0.0 17 | 18 | upgrade_Template() 19 | { 20 | BRED; echo "MONERO-BASH [$BRANCH] INSTALL" ;OFF 21 | 22 | cd "$tmp" 23 | cp -r $HOME/git/monero-bash "$tmp" 24 | cd monero-bash 25 | git checkout $BRANCH 26 | NewVer="$(git rev-parse --short HEAD)" 27 | 28 | # TEMP FOLDER FOR OLD PACKAGE 29 | folderName="$(ls $tmp)" 30 | if [[ -d "$old" ]]; then 31 | sudo -u "$USER" rm -rf "$old" 32 | error_Exit "Could not remove old folder" 33 | fi 34 | 35 | # SAFETY CHECKS 36 | [[ "$folderName" = "" || "$tmp" = "" ]]&& echo "EMPTY TMP VARIABLE, EXITING FOR SAFETY" &&exit 37 | mkdir -p "$old" 38 | 39 | # INSTALL FOR MONERO_BASH 40 | if [[ "$NAME_CAPS" = "MONERO_BASH" ]]; then 41 | trap "trap_Old" 1 2 3 6 15 42 | sudo -u "$USER" cp "$installDirectory/monero-bash" "$old" 43 | sudo -u "$USER" cp -fr "$installDirectory/src" "$old" 44 | sudo -u "$USER" cp -fr "$installDirectory/config" "$old" 45 | sudo -u "$USER" cp -fr "$installDirectory/gpg" "$old" 46 | trap "trap_MoneroBash" 1 2 3 6 15 47 | sudo -u "$USER" cp -fr "$tmp/$folderName/monero-bash" "$installDirectory" 48 | sudo -u "$USER" cp -fr "$tmp/$folderName/src" "$installDirectory" 49 | sudo -u "$USER" cp -fr "$tmp/$folderName/config" "$installDirectory" 50 | sudo -u "$USER" cp -fr "$tmp/$folderName/gpg" "$installDirectory" 51 | sudo -u "$USER" cp -fr "$old/src/txt/state" "$state" 52 | sudo -u "$USER" cp -fr "$old/src/mini" "$installDirectory/src/" 53 | fi 54 | upgrade_Post 55 | } 56 | 57 | version_Template() 58 | { 59 | echo no_ver 60 | } 61 | 62 | QUIET_HASH_LIST() 63 | { 64 | echo no_hash 65 | } 66 | 67 | FORCE_UPGRADE="true" 68 | upgrade_MoneroBash 69 | monero-bash DEBUG_04e3be9 PRODUCE_HASH_LIST 70 | --------------------------------------------------------------------------------