diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 37589574ab..18331bf1ed 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -1012,6 +1012,12 @@ Available commands: aSOFTWARE_DOCS[$software_id]='https://dietpi.com/docs/software/social/#wordpress' aSOFTWARE_DEPS[$software_id]='88 89 webserver' #------------------ + software_id=141 + aSOFTWARE_NAME[$software_id]='Hugo' + aSOFTWARE_DESC[$software_id]='A static-site generator for building websites' + aSOFTWARE_CATX[$software_id]=6 + aSOFTWARE_DOCS[$software_id]='https://dietpi.com/docs/software/social/#hugo' + #------------------ software_id=38 aSOFTWARE_NAME[$software_id]='FreshRSS' aSOFTWARE_DESC[$software_id]='self-hosted RSS feed aggregator' @@ -7079,6 +7085,104 @@ _EOF_ /boot/dietpi/func/create_mysql_db wordpress wordpress "$GLOBAL_PW" fi + if To_Install 141 # Hugo + then + hdir=/mnt/dietpi_userdata/hugo + G_AGI hugo + G_EXEC mkdir -p "$hdir" + Create_User -d "$hdir" hugo + + G_EXEC cd "$hdir" + if ! [[ -d "${hdir}/mysite" ]]; then + G_EXEC hugo new site mysite -f toml + fi + G_EXEC cd "${hdir}/mysite" + if ! [[ -d themes/PaperMod ]]; then + Download_Install "https://github.com/adityatelange/hugo-PaperMod/archive/master.tar.gz" "${hdir}/mysite" + G_EXEC mv "${hdir}/mysite/hugo-PaperMod-master" "${hdir}/mysite/themes/PaperMod" + fi + + ## Create a default config with a default theme + cat << _EOF_ > config.toml +baseURL = 'http://$(G_GET_NET ip)' +title = 'DietPi Test Blog' +languageCode = 'en-us' +theme = "PaperMod" + +[markup.goldmark.renderer] + unsafe = true + +_EOF_ + ## Create a systemd file + cat << '_EOF_' > /etc/systemd/system/hugo.service +[Unit] +Description=Hugo (DietPi) +Wants=network-online.target +After=network-online.target + +[Service] +SyslogIdentifier=Hugo +User=hugo +LogsDirectory=hugo +WorkingDirectory=/mnt/dietpi_userdata/hugo/mysite +ExecStart=/usr/bin/hugo server -p 8131 --buildDrafts --navigateToChanged + +[Install] +WantedBy=multi-user.target + +_EOF_ + + ## Create first post + G_EXEC mkdir -p "${hdir}/mysite/content/posts/" + cat << '_EOF_' > "${hdir}/mysite/content/posts/first.md" +--- +title: "First Post" +date: 2023-01-01 +draft: false +--- + +# The website is up! + +This is the first post, which was generated by running the command + +```bash +cd /mnt/dietpi_userdata/hugo/mysite/ +sudo -u hugo hugo new posts/name-of-post.md +## Note that the '.md' extension is important +``` + +You can then modify the file with a markdown editor, and it will +update in real time. + +e.g. `sudo -u hugo nano /mnt/dietpi_userdata/hugo/mysite/content/posts/name-of-post.md` + +Please also see the [Quick Start](https://gohugo.io/getting-started/quick-start/) +guide for more configuration tips! + +This also allows you to **push** markdown snippets to your DietPi + +e.g. `rsync random-note.md dietpi@my.website.com:/mnt/dietpi_userdata/hugo/mysite/content/posts/` + +## Extras + +If you are an Emacs fan, you can use the +[ox-hugo](https://ox-hugo.scripter.co/doc/installation/) package to +export an org-mode sub-tree as a post, allowing you to blog on-the-fly +from your editor! + +# Configuration + +Hugo's themes can be changed by editing the `/mnt/dietpi_userdata/hugo/mysite/config.toml` +file. See the [Configuration Guide](https://gohugo.io/getting-started/configuration/) for +inspiration. + +Hugo server options need to be changed from the command line. This means ports, baseURL, and +site directory need to be edited in the systemd file, located at: `/etc/systemd/system/hugo.service` + +_EOF_ + G_EXEC chown hugo: -R "$hdir" + fi + if To_Install 38 # FreshRSS then # Install required PHP modules: https://github.com/FreshRSS/FreshRSS#requirements @@ -13115,6 +13219,12 @@ If no WireGuard (auto)start is included, but you require it, please do the follo Remove_Database wordpress fi + if To_Uninstall 141 # WordPress + then + Remove_Service hugo + G_AGP hugo + fi + if To_Uninstall 38 # FreshRSS then crontab -u www-data -l | grep -v '/opt/FreshRSS/app/actualize_script.php' | crontab -u www-data -