when the update_fortune task runs, it will now copy the template index if it's not present at the folder
This commit is contained in:
parent
74412bbae8
commit
d8962c82b0
@ -3,6 +3,7 @@ Description=Generate a new fortune for the cygnus landing page.
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
WorkingDirectory = /home/shoofle/cygnus
|
||||||
ExecStart=python /home/shoofle/cygnus/update_fortune.py
|
ExecStart=python /home/shoofle/cygnus/update_fortune.py
|
||||||
User=shoofle
|
User=shoofle
|
||||||
|
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
file_name = "/var/www/html/index.html"
|
||||||
|
|
||||||
|
#if the file doesn't exist, we should copy the template to the folder
|
||||||
|
if not os.exists(file_name):
|
||||||
|
template_name = "index.html"
|
||||||
|
shutil.copy(template_name, file_name)
|
||||||
|
print("The index file was not available, so we've restored it from template.")
|
||||||
|
|
||||||
fortune = os.popen("/usr/games/fortune | /usr/games/cowsay").read()
|
fortune = os.popen("/usr/games/fortune | /usr/games/cowsay").read()
|
||||||
|
|
||||||
file_name = "/var/www/html/index.html"
|
|
||||||
soup = None
|
soup = None
|
||||||
|
|
||||||
print("The emergency fortune system has set the fortune to {}".format(fortune))
|
print("The emergency fortune system has set the fortune to {}".format(fortune))
|
||||||
|
Loading…
Reference in New Issue
Block a user