pass variable to sh script

main
vitrinekast 10 months ago
parent abcb6c9661
commit a4fe49aef5

@ -1,9 +1,7 @@
#!/bin/bash
today=`date '+%B_%dth_%Y'`;
filename="TD;DR_$today"
echo $filename;
echo "execute a bash script that will create a book called " + $1
pandoc /home/xpub/www/html/tl-dr/book.html -o /home/xpub/www/html/tl-dr/logged_book.epub -c print.css --metadata title=$1 --epub-cover-image=cover.jpg --epub-embed-font='fonts/Cascadia/ttf/CascadiaCode-Light.ttf' --epub-embed-font='fonts/Ductus/DuctusRegular.otf'
cp /home/xpub/www/html/tl-dr/logged_book.epub /home/xpub/www/html/tl-dr/log-books/$1.epub
pandoc /home/xpub/www/html/tl-dr/book.html -o /home/xpub/www/html/tl-dr/logged_book.epub -c print.css --metadata title=$filename --epub-cover-image=cover.jpg --epub-embed-font='fonts/Cascadia/ttf/CascadiaCode-Light.ttf' --epub-embed-font='fonts/Ductus/DuctusRegular.otf'
cp /home/xpub/www/html/tl-dr/logged_book.epub /home/xpub/www/html/tl-dr/log-books/$filename.epub
echo "did the overwrite"
ls log-books > /home/xpub/www/html/tl-dr/log-books/all.txt

@ -8,12 +8,10 @@ import fnmatch
path = "/home/xpub/www/html/tl-dr/log-books"
if not os.path.exists(path):
os.makedirs(path)
# TODO: check sorting of these files (should be chronological)
# Getting the dynamic variables
log_files = fnmatch.filter(os.listdir(path), '*.epub')
now = datetime.today()
next_report = now + timedelta(hours=3)
log_file_name = "TL;DR_" + now.strftime("%B %dth %Y")
book_name = "TL;DR_" + now.strftime("%B %dth %Y")
def create_all_logs_file():
list_logs = subprocess.run(["ls", "/home/xpub/www/html/tl-dr/log-books"], capture_output=True)
@ -71,8 +69,6 @@ template = env.get_template("book.jinja")
# rendering the template and storing the resultant text in variable output
output = template.render(
now = now.strftime("%B %dth %Y"),
next_report = next_report,
log_files = log_files,
last_user_added=last_user_added.stdout.decode('UTF-8'),
last_user_added_name=last_user_added_name,
users_created_today=users_created_today,
@ -103,7 +99,7 @@ print("Output the files");
with open("/home/xpub/www/html/tl-dr/book.html", "w") as f:
print(output, file=f)
print("execute the bash script now to create the books");
subprocess.run(['sh', 'create_book.sh'])
subprocess.run(['sh', 'create_book.sh', 'book_name'])
print("Finished");
# At the moment, we are not storing logs in the log folder anymore

Loading…
Cancel
Save