Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dietpi-Software | Hugo: A static-site generator for building websites #6487

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions dietpi/dietpi-software
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -7079,6 +7085,82 @@ _EOF_
/boot/dietpi/func/create_mysql_db wordpress wordpress "$GLOBAL_PW"
fi

if To_Install 141 # Hugo
then
aDEPS=("git")
mtekman marked this conversation as resolved.
Show resolved Hide resolved
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'
mtekman marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it really log to /var/log/hugo, or can it be configured to log to STDOUT instead?

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
Expand Down Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
G_AGP hugo
G_AGP hugo
[[ -f '/mnt/dietpi_userdata/hugo' ]] && G_EXEC rm -R /mnt/dietpi_userdata/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 -
Expand Down