From 55d9683dfb5a2b55a8f7d203da7bc25be9a19385 Mon Sep 17 00:00:00 2001 From: MT Date: Mon, 17 Jul 2023 17:27:30 +0200 Subject: [PATCH 1/7] add hugo static server --- dietpi/dietpi-software | 88 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 37589574ab..9af917b5ef 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,82 @@ _EOF_ /boot/dietpi/func/create_mysql_db wordpress wordpress "$GLOBAL_PW" fi + if To_Install 141 # Hugo + then + aDEPS=("git") + G_AGI hugo + G_EXEC mkdir -p /mnt/dietpi_userdata/hugo + Create_User -d /mnt/dietpi_userdata/hugo hugo + + G_EXEC cd /mnt/dietpi_userdata/hugo + if ! [ -d /mnt/dietpi_userdata/hugo/mysite ]; then + G_EXEC hugo new site mysite -f toml + fi + + G_EXEC cd /mnt/dietpi_userdata/hugo/mysite + if ! [ -d themes/PaperMod ]; then + G_EXEC git clone https://github.com/adityatelange/hugo-PaperMod themes/PaperMod --depth=1 + fi + + ## Create a default config with a default theme + cat << '_EOF_' > config.toml +baseURL = 'http://my.website.com' +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 /mnt/dietpi_userdata/hugo/mysite/content/posts/ + cat << '_EOF_' > /mnt/dietpi_userdata/hugo/mysite/content/posts/first.md +--- +title: "First Post" +date: $(date -I) +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. + +Please also see the [Quick Start](https://gohugo.io/getting-started/quick-start/) +guide for more configuration tips! + +_EOF_ + + G_EXEC chown hugo: -R /mnt/dietpi_userdata/hugo/ + fi + if To_Install 38 # FreshRSS then # Install required PHP modules: https://github.com/FreshRSS/FreshRSS#requirements @@ -13115,6 +13197,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 - From 8e89aca012e0c77bb1c32d9ff4c4b39a1868b792 Mon Sep 17 00:00:00 2001 From: MT Date: Mon, 17 Jul 2023 18:45:58 +0200 Subject: [PATCH 2/7] shellfix --- dietpi/dietpi-software | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 9af917b5ef..32e3c1657c 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -7093,12 +7093,12 @@ _EOF_ Create_User -d /mnt/dietpi_userdata/hugo hugo G_EXEC cd /mnt/dietpi_userdata/hugo - if ! [ -d /mnt/dietpi_userdata/hugo/mysite ]; then + if ! [[ -d /mnt/dietpi_userdata/hugo/mysite ]]; then G_EXEC hugo new site mysite -f toml fi G_EXEC cd /mnt/dietpi_userdata/hugo/mysite - if ! [ -d themes/PaperMod ]; then + if ! [[ -d themes/PaperMod ]]; then G_EXEC git clone https://github.com/adityatelange/hugo-PaperMod themes/PaperMod --depth=1 fi From 1544a7d4bb1505a8e62b435472b751dc13498e5d Mon Sep 17 00:00:00 2001 From: MT Date: Tue, 18 Jul 2023 09:38:18 +0200 Subject: [PATCH 3/7] common path to variable, removed git, extended first post --- dietpi/dietpi-software | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 32e3c1657c..085ce6e80c 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -7087,19 +7087,19 @@ _EOF_ if To_Install 141 # Hugo then - aDEPS=("git") + hdir=/mnt/dietpi_userdata/hugo G_AGI hugo - G_EXEC mkdir -p /mnt/dietpi_userdata/hugo - Create_User -d /mnt/dietpi_userdata/hugo hugo + G_EXEC mkdir -p "$hdir" + Create_User -d "$hdir" hugo - G_EXEC cd /mnt/dietpi_userdata/hugo - if ! [[ -d /mnt/dietpi_userdata/hugo/mysite ]]; then + G_EXEC cd "$hdir" + if ! [[ -d "${hdir}/mysite" ]]; then G_EXEC hugo new site mysite -f toml fi - - G_EXEC cd /mnt/dietpi_userdata/hugo/mysite + G_EXEC cd "${hdir}/mysite" if ! [[ -d themes/PaperMod ]]; then - G_EXEC git clone https://github.com/adityatelange/hugo-PaperMod themes/PaperMod --depth=1 + 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 @@ -7133,8 +7133,8 @@ WantedBy=multi-user.target _EOF_ ## Create first post - G_EXEC mkdir -p /mnt/dietpi_userdata/hugo/mysite/content/posts/ - cat << '_EOF_' > /mnt/dietpi_userdata/hugo/mysite/content/posts/first.md + G_EXEC mkdir -p "${hdir}/mysite/content/posts/" + cat << '_EOF_' > "${hdir}/mysite/content/posts/first.md" --- title: "First Post" date: $(date -I) @@ -7151,14 +7151,28 @@ 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. +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! + _EOF_ - G_EXEC chown hugo: -R /mnt/dietpi_userdata/hugo/ + G_EXEC chown hugo: -R "$hdir" fi if To_Install 38 # FreshRSS From c6d57bc44ce0efb010fdb47799bbc22de00a1740 Mon Sep 17 00:00:00 2001 From: MT Date: Tue, 18 Jul 2023 09:41:18 +0200 Subject: [PATCH 4/7] real date --- dietpi/dietpi-software | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 085ce6e80c..eb69eee6b7 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -7137,7 +7137,7 @@ _EOF_ cat << '_EOF_' > "${hdir}/mysite/content/posts/first.md" --- title: "First Post" -date: $(date -I) +date: 2023-01-01 draft: false --- From f3e0e1017fda5b3d13b0765ddfcabeefc29a9ad0 Mon Sep 17 00:00:00 2001 From: MT Date: Wed, 19 Jul 2023 12:29:28 +0200 Subject: [PATCH 5/7] added more information about configuration --- dietpi/dietpi-software | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index eb69eee6b7..fb734a3bc5 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -7170,6 +7170,16 @@ If you are an Emacs fan, you can use the 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" From 8b5e411ab58a61a27903b22bba8fda18dd9698a2 Mon Sep 17 00:00:00 2001 From: MT Date: Wed, 19 Jul 2023 12:39:46 +0200 Subject: [PATCH 6/7] shellfish --- dietpi/dietpi-software | 2 -- 1 file changed, 2 deletions(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index fb734a3bc5..fdd0525290 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -7179,9 +7179,7 @@ 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 From 5eceef021b65aec2caf45650260d41089560bb6d Mon Sep 17 00:00:00 2001 From: mtekman <20641402+mtekman@users.noreply.github.com> Date: Tue, 25 Jul 2023 08:27:52 +0000 Subject: [PATCH 7/7] Update dietpi/dietpi-software Co-authored-by: MichaIng --- dietpi/dietpi-software | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index fdd0525290..18331bf1ed 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -7103,8 +7103,8 @@ _EOF_ fi ## Create a default config with a default theme - cat << '_EOF_' > config.toml -baseURL = 'http://my.website.com' + cat << _EOF_ > config.toml +baseURL = 'http://$(G_GET_NET ip)' title = 'DietPi Test Blog' languageCode = 'en-us' theme = "PaperMod"