Просмотр исходного кода

added a script that adds files after the computer has been started

master
Wouter Horlings 6 лет назад
Родитель
Сommit
b40f30fd5b
4 измененных файлов: 47 добавлений и 12 удалений
  1. +12
    -0
      createfile.py
  2. +9
    -0
      systemd_timer_files/pythoncreatelog.service
  3. +9
    -0
      systemd_timer_files/pythoncreatelog.timer
  4. +17
    -12
      systemd_timer_files/settimer.sh

+ 12
- 0
createfile.py Просмотреть файл

@@ -0,0 +1,12 @@
from datetime import date

def createfile():
filenames = ["1Start","2Middle","3End"]
todaystr = date.today().strftime("%y%m%d")
if date.today().weekday() < 5:
for filename in filenames:
with open("journal/"+todaystr+"_"+filename,"w") as fh:
pass

if __name__ == '__main__':
createfile()

+ 9
- 0
systemd_timer_files/pythoncreatelog.service Просмотреть файл

@@ -0,0 +1,9 @@
[Unit]
Description="Executes the script that creates the log files needed for today"

[Service]
WorkingDirectory=[[path_to_repo]]
ExecStart=[[path_to_repo]]/.venv/bin/python3 [[path_to_repo]]/createfile.py

[Install]
WantedBy=default.target

+ 9
- 0
systemd_timer_files/pythoncreatelog.timer Просмотреть файл

@@ -0,0 +1,9 @@
[Unit]
Description="Create the logfiles of today"

[Timer]
OnBootSec=1min
Unit=pythoncreatelog.service

[Install]
WantedBy=default.target

+ 17
- 12
systemd_timer_files/settimer.sh Просмотреть файл

@@ -10,6 +10,20 @@ replace_and_move() {
echo "$1 script placed at $OUTDIR"
}

setfile() {
TIMERNAME="$1.timer"
SERVICENAME="$1.service"
replace_and_move $TIMERNAME $MAPPATH
replace_and_move $SERVICENAME $MAPPATH
echo "Reload systemd deamon"
`systemctl --user daemon-reload`
echo "Enable $TIMERNAME for systemd"
`systemctl --user enable $TIMERNAME`
echo "Start $TIMERNAME for systemd"
`systemctl --user start $TIMERNAME`
}


###################
# START OF SCRIPT #
###################
@@ -36,20 +50,11 @@ else
exit
fi

FILENAME="pythontaskcheck"
FOLDERNAME="systemd_timer_files"
MAPPATH="$GIT_DIR/$FOLDERNAME/"
TIMERNAME="$FILENAME.timer"
SERVICENAME="$FILENAME.service"
replace_and_move $TIMERNAME $MAPPATH
replace_and_move $SERVICENAME $MAPPATH

echo "Reload systemd deamon"
`systemctl --user daemon-reload`
echo "Enable $TIMERNAME for systemd"
`systemctl --user enable $TIMERNAME`
echo "Start $TIMERNAME for systemd"
`systemctl --user start $TIMERNAME`
setfile "pythontaskcheck"
setfile "pythoncreatelog"






Загрузка…
Отмена
Сохранить