Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make update_nfx_docker_compose.sh works with docker compose #475

Merged
merged 5 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tools/simple_updater_docker.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

#Fork of https://github.com/lobap/NostalgiaForInfinity_Update/blob/master/NostalgiaForInfinity_Update.sh
#Changed a little bit by Yogabba (becouse for some reason didnt want to restart docker after update)
#Changed a little bit by Yogabba (because for some reason didn't want to restart docker after update)
#Update to latest tag
#need to add to crontab by typing "crontab -e" in terminal "
# */60 * * * * /bin/bash -c "ft_userdata/user_data/tools/simple_update.sh
#


#!/bin/bash

ROOT_PATH="Your root path f.e. (/home/user"
ROOT_PATH="Your root path f.e. (/home/user)"
NFI_PATH="${ROOT_PATH}/NFI/NostalgiaForInfinityX.py"
FT_PATH="${ROOT_PATH}/ft_userdata/user_data/strategies/NostalgiaForInfinityX.py"
TG_TOKEN=""
Expand Down
Empty file modified tools/update_nfx.sh
100644 → 100755
Empty file.
50 changes: 15 additions & 35 deletions tools/update_nfx_docker_compose.sh
Original file line number Diff line number Diff line change
@@ -1,45 +1,25 @@
#!/bin/sh

### Prereqs:
## 1. Freqtrade setup to run via docker-compose
## 2. A directory with the NFI repo with the NFI master branch
## 1. A directory with the NFIX repo setup on the main branch to run via docker compose

### Simple script that does the following:
## 1. Pulls latest NFI Repo
## 2. Copies updated NFIX sxtrategy file to Freqtrade
## 3. Optionally Commits the update strategy to a local repo
## 4. Stops, Build, and Start freqtrader via docker-compose
## 1. Pull NFIX repo
## 2. Stop, Pull, and Start freqtrader via docker compose
## 3. Add this script to a cron job to run at a specific interval: */60 * * * * /path/to/update_nfx_docker_compose.sh

NFI_REPO_HOME=/root/freqtrade/NostalgiaForInfinity
FREQTRADE_HOME=/root/freqtrade/freqtrade-docker/ft_userdata
COMMIT_TO_LOCAL_REPO=true
NFI_LOCAL_REPO=/home/user/NostalgiaForInfinity

#pull latest NFIX strategy and copy to freqtrade
echo "updating NFO Strategy"
cd $NFI_REPO_HOME
# pull from NFIX repo
echo "updating local NFIX repo"
cd $NFI_LOCAL_REPO
latest_local_commit=$(git rev-parse HEAD)
git pull
cp NostalgiaForInfinityX.py $FREQTRADE_HOME/user_data/strategies
echo "copied NFI Strategy to freqtrader"

#optionally add the update strategy file to your own repo
if [ "$COMMIT_TO_LOCAL_REPO" = true ] ; then
echo 'Commiting updates to local repo'

#ensure local repo to up to date
echo "added updates strategy to git"
cd $FREQTRADE_HOME
git pull

#commit update strategy file to local repo
cd $FREQTRADE_HOME/user_data/strategies
git add NostalgiaForInfinityX.py
git commit -m "updated nfix strategy"
git push
latest_remote_commit=$(git rev-parse HEAD)

if [ "$latest_local_commit" != "$latest_remote_commit" ]; then
echo "restarting freqtrade with NFIX"
docker compose pull
docker compose stop
docker compose up -d
fi

#build and start via docker compose
echo "Starting freqtrade with NFIX"
docker-compose stop
docker-compose build
docker-compose up -d
Loading