summaryrefslogtreecommitdiffstats
path: root/emacsconf-stream.el
diff options
context:
space:
mode:
authorSacha Chua <sacha@sachachua.com>2023-10-22 08:46:10 -0400
committerSacha Chua <sacha@sachachua.com>2023-10-22 08:46:10 -0400
commit3fceb4321bff25f5d8a4c2eb4c23cfda756708da (patch)
tree1d453b36be98d71557848600de2bcad4e59bd9d1 /emacsconf-stream.el
parent3d62512ddc7cdd591b26e494ea4538d439b1e2b6 (diff)
downloademacsconf-el-3fceb4321bff25f5d8a4c2eb4c23cfda756708da.tar.xz
emacsconf-el-3fceb4321bff25f5d8a4c2eb4c23cfda756708da.zip
autopilot with crontab
Diffstat (limited to 'emacsconf-stream.el')
-rw-r--r--emacsconf-stream.el44
1 files changed, 43 insertions, 1 deletions
diff --git a/emacsconf-stream.el b/emacsconf-stream.el
index b994640..b117ed6 100644
--- a/emacsconf-stream.el
+++ b/emacsconf-stream.el
@@ -1063,9 +1063,51 @@ ffplay URL
(plist-put (emacsconf-get-track track)
:status (or status (completing-read "Status: " '("online" "offline"))))
(emacsconf-stream-update-status-page))
-
+
(defun emacsconf-stream-edit-status-page ()
(interactive)
(find-file "/ssh:orga@front0.emacsconf.org:/var/www/status.emacsconf.org/index.html"))
+
+;;; Autopilot with crontab
+
+(defun emacsconf-stream-format-crontab (track talks &optional test-mode)
+ "Return crontab entries for TALKS.
+Use the display specified in TRACK.
+If TEST-MODE is non-nil, load the videos from the test directory."
+ (concat
+ "PATH=/usr/local/bin:/usr/bin\n"
+ "MAILTO=\"\"\n"
+ (mapconcat
+ (lambda (talk)
+ (format "%s /usr/bin/screen -dmS play-%s bash -c \"DISPLAY=%s TEST_MODE=%s /usr/local/bin/handle-session %s\"\n"
+ ;; cron times are UTC
+ (format-time-string "%-M %-H %-d %m *" (plist-get talk :start-time))
+ (plist-get talk :slug)
+ (plist-get track :vnc-display)
+ (if test-mode "1" "")
+ (plist-get talk :slug)))
+ (emacsconf-filter-talks talks))))
+
+(defun emacsconf-stream-crontabs (&optional test-mode info)
+ (interactive)
+ (let ((emacsconf-publishing-phase 'conference))
+ (setq info (or info (emacsconf-publish-prepare-for-display (emacsconf-get-talk-info))))
+ (dolist (track emacsconf-tracks)
+ (let ((talks (seq-filter (lambda (talk)
+ (string= (plist-get talk :track)
+ (plist-get track :name)))
+ info))
+ (crontab (expand-file-name (concat (plist-get track :id) ".crontab")
+ (concat (plist-get track :tramp) "~"))))
+ (with-temp-file crontab
+ (when (plist-get track :auto-pilot)
+ (insert (emacsconf-stream-format-crontab track talks test-mode))))
+ (emacsconf-stream-track-ssh track (concat "crontab ~/" (plist-get track :id) ".crontab"))))))
+
+(defun emacsconf-stream-cancel-crontab (track)
+ "Remove crontab for TRACK."
+ (interactive (list (emacsconf-complete-track)))
+ (emacsconf-stream-track-ssh track "crontab -r"))
+;;;
(provide 'emacsconf-stream)
;;; emacsconf-stream.el ends here