Skip to content

Commit

Permalink
Move persistent files to data directory during setup
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptosharks131 committed Jan 18, 2022
1 parent f63b7e7 commit ad862a0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,24 @@ Start by choosing one of the following installation methods:
### Build and deploy
1. Clone respository `git clone https://github.com/cryptosharks131/lndg.git`
2. Change directory into the repo `cd lndg`
3. Initialize db and admin backup `touch db.sqlite3 && touch lndg-admin.txt`
4. Copy and replace the contents (adjust custom volume paths to LND and LNDg folders) of the `docker-compose.yaml` with the below: `nano docker-compose.yaml`
3. Copy and replace the contents (adjust custom volume paths to LND and LNDg folders) of the `docker-compose.yaml` with the below: `nano docker-compose.yaml`
```
services:
lndg:
build: .
volumes:
- /home/<user>/.lnd:/root/.lnd:ro
- /home/<user>/<path-to>/lndg/db.sqlite3:/lndg/db.sqlite3:rw
- /home/<user>/<path-to/lndg/lndg-admin.txt:/lndg/lndg-admin.txt:rw
- /home/<user>/<path-to>/lndg/data:/lndg/data:rw
command:
- sh
- -c
- python initialize.py -net 'mainnet' -server '127.0.0.1:10009' -d && supervisord && python manage.py runserver 0.0.0.0:8889
network_mode: "host"
```
5. Deploy your docker image: `docker-compose up -d`
6. LNDg should now be available on port `http://localhost:8889`
7. Open and copy the password from output file: `nano lndg-admin.txt`
8. Use the password from the output file and the username `lndg-admin` to login
4. Deploy your docker image: `docker-compose up -d`
5. LNDg should now be available on port `http://localhost:8889`
6. Open and copy the password from output file: `nano lndg-admin.txt`
7. Use the password from the output file and the username `lndg-admin` to login

### Updating
```
Expand All @@ -41,16 +39,14 @@ docker-compose up -d
1. Log into your umbrel via ssh
2. Clone respository `git clone https://github.com/cryptosharks131/lndg.git`
3. Change directory `cd lndg`
4. Initialize db and admin backup `touch db.sqlite3 && touch lndg-admin.txt`
5. Copy and replace the contents of the `docker-compose.yaml` with the below: `nano docker-compose.yaml`
4. Copy and replace the contents of the `docker-compose.yaml` with the below: `nano docker-compose.yaml`
```
services:
lndg:
build: .
volumes:
- /home/umbrel/umbrel/lnd:/root/.lnd:ro
- /home/umbrel/lndg/db.sqlite3:/lndg/db.sqlite3:rw
- /home/umbrel/lndg/lndg-admin.txt:/lndg/lndg-admin.txt:rw
- /home/umbrel/lndg/data:/lndg/data:rw
command:
- sh
- -c
Expand Down Expand Up @@ -82,7 +78,7 @@ docker-compose up -d
4. Setup a python3 virtual environment `virtualenv -p python3 .venv`
5. Install required dependencies `.venv/bin/pip install -r requirements.txt`
6. Initialize some settings for your django site (see notes below) `.venv/bin/python initialize.py`
7. The initial login user is `lndg-admin` and the password is output here: `lndg-admin.txt`
7. The initial login user is `lndg-admin` and the password is output here: `data/lndg-admin.txt`
8. Generate some initial data for your dashboard `.venv/bin/python jobs.py`
9. Run the server via a python development server `.venv/bin/python manage.py runserver 0.0.0.0:8889`
Tip: If you plan to only use the development server, you will need to setup whitenoise (see note below).
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ services:
build: .
volumes:
- /root/.lnd:/root/.lnd:ro
- /root/lndg/db.sqlite3:/lndg/db.sqlite3:rw
- /root/lndg/lndg-admin.txt:/lndg/lndg-admin.txt:rw
- /root/lndg/data:/lndg/data:rw
command:
- sh
- -c
Expand Down
15 changes: 11 additions & 4 deletions initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def write_settings(node_ip, lnd_dir_path, lnd_network, lnd_rpc_server, whitenois
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'NAME': BASE_DIR / 'data/db.sqlite3',
}
}
Expand Down Expand Up @@ -236,7 +236,7 @@ def write_supervisord_settings(sduser):
print('Error creating the settings file:', str(e))

def main():
help_msg = "LNDg Settings Initializer"
help_msg = "LNDg Initializer"
parser = argparse.ArgumentParser(description = help_msg)
parser.add_argument('-ip', '--nodeip',help = 'IP that will be used to access the LNDg page', default='*')
parser.add_argument('-dir', '--lnddir',help = 'LND Directory for tls cert and admin macaroon paths', default='~/.lnd')
Expand Down Expand Up @@ -267,12 +267,18 @@ def main():
print('Supervisord setup requested...')
write_supervisord_settings(sduser)
try:
DATA_DIR = os.path.join(BASE_DIR, 'data')
try:
os.mkdir(DATA_DIR)
except:
print('Data directory already found...')
Path(os.path.join(DATA_DIR, 'db.sqlite3')).touch()
settings.configure(
SECRET_KEY = secrets.token_urlsafe(64),
DATABASES = {
'default':{
'ENGINE':'django.db.backends.sqlite3',
'NAME':BASE_DIR/'db.sqlite3'
'NAME': BASE_DIR / 'data/db.sqlite3'
}
},
INSTALLED_APPS = [
Expand Down Expand Up @@ -301,7 +307,8 @@ def main():
admin.save()
if adminpw is None:
try:
f = open("lndg-admin.txt", "w")
Path(os.path.join(DATA_DIR, 'lndg-admin.txt')).touch()
f = open('data/lndg-admin.txt', 'w')
f.write(login_pw)
f.close()
except Exception as e:
Expand Down

0 comments on commit ad862a0

Please sign in to comment.