Compare commits

...

2 Commits

Author SHA1 Message Date
Ray Elliott ce08c3d4d8 add option to install theme with hugo 2020-03-20 16:24:28 +00:00
Ray Elliott 4be6fdc622 install hugo 2020-03-20 14:36:53 +00:00
2 changed files with 64 additions and 2 deletions

View File

@ -1,5 +1,11 @@
export _url="hugo-skeleton.home"
export _user='ray'
export _url=hugo-skeleton.home
export _user=ray
export _node_version=v12.16.1
export _node_distro=linux-x64
export _hugo_version=0.67.1
export _hugo_distro=Linux-64
export _hugo_theme_git_url=https://github.com/dirkolbrich/hugo-theme-tailwindcss-starter
export _hugo_theme_name=hugo-theme-tailwindcss-starter
export _hugo_site_name=hugo-site-tailwindcss-starter

56
dev-setup/hugo.sh Executable file
View File

@ -0,0 +1,56 @@
#!/bin/sh
set -e
_cmd_su="su --login $_user -c"
_site_path="/home/$_user/$_hugo_site_name"
_theme_path="$_site_path/themes/$_hugo_theme_name"
_serve_script_path="$_site_path/hugo-serve.sh"
_build_script_path="$_site_path/hugo-build.sh"
if ! command -v hugo ; then
if command -v apt-get ; then
wget https://github.com/gohugoio/hugo/releases/download/v"$_hugo_version"/hugo_extended_"$_hugo_version"_"$_hugo_distro"bit.deb -O /tmp/hugo.deb
apt-get install /tmp/hugo.deb
else
echo 'hugo.sh: Error - no installation method available for `hugo` executable'
exit 1;
fi
fi
if command -v yarn ; then
$_cmd_su 'yarn global add postcss-cli autoprefixer'
else
echo 'hugo.sh: Error - `yarn` executable not found'
exit 1
fi
$_cmd_su "cd ~ && hugo new site $_hugo_site_name"
if [ -z "$_hugo_theme_git_url" ] ; then
exit
fi
$_cmd_su "git clone $_hugo_theme_git_url $_theme_path"
$_cmd_su " rm -Rf $_theme_path/.git"
$_cmd_su "cd $_theme_path && git init"
$_cmd_su "cd $_theme_path && yarn install"
echo "theme = \"$_hugo_theme_name\"" >> $_site_path/config.toml
echo "#!/bin/sh" > "$_serve_script_path"
echo 'echo "sudo required to bind to port 80"' >> "$_serve_script_path"
echo "sudo hugo server -D --bind=0.0.0.0 --baseURL=http://$_url -p80" >> "$_serve_script_path"
chown "$_user": "$_serve_script_path"
chmod +x "$_serve_script_path"
cat << EOF > "$_build_script_path"
#!/bin/sh
touch ./public
rm -R ./public
hugo -v
EOF
chown "$_user": "$_build_script_path"
chmod +x "$_build_script_path"