From 136f64ac309c677a01216a23e7878cd1a2d60a32 Mon Sep 17 00:00:00 2001 From: danix Date: Thu, 16 Feb 2023 19:34:19 +0100 Subject: [PATCH] updated some articles --- content/articles/ceasar-quote.md | 14 +---- content/articles/conquista-la-folla.md | 10 +--- content/articles/git-setup-own-server.md | 72 +++++++++++++++--------- content/is/_index.md | 6 +- 4 files changed, 55 insertions(+), 47 deletions(-) diff --git a/content/articles/ceasar-quote.md b/content/articles/ceasar-quote.md index 128cd79..df13e37 100644 --- a/content/articles/ceasar-quote.md +++ b/content/articles/ceasar-quote.md @@ -10,15 +10,7 @@ tags: - Ceasar - quote format: quote - --- -
-

- What we wish, we readily believe, and what we ourselves think, we imagine others think also. -

- - Caesar -
- -

-

\ No newline at end of file +{{< quote source="Julius Caesar" >}} +What we wish, we readily believe, and what we ourselves think, we imagine others think also. +{{< /quote >}} \ No newline at end of file diff --git a/content/articles/conquista-la-folla.md b/content/articles/conquista-la-folla.md index b78d75a..56fb2e5 100644 --- a/content/articles/conquista-la-folla.md +++ b/content/articles/conquista-la-folla.md @@ -11,10 +11,6 @@ tags: format: quote --- -
-

- conquisterò la folla… gli darò qualcosa che non ha mai visto prima -

- - Massimo X Meridio -
\ No newline at end of file +{{< quote source="Massimo X Meridio" >}} +conquisterò la folla… gli darò qualcosa che non ha mai visto prima +{{< /quote >}} \ No newline at end of file diff --git a/content/articles/git-setup-own-server.md b/content/articles/git-setup-own-server.md index e83cb9d..a4b0ca0 100644 --- a/content/articles/git-setup-own-server.md +++ b/content/articles/git-setup-own-server.md @@ -5,8 +5,17 @@ type: post author: "danix" excerpt: "I'll show you how to setup your own git server easily" featured_image: "uploads/2018/07/gitout.jpg" -tags: ["git", "server", "setup", "howto", "do it yourself", "ssh"] -categories: ["code", "diy", "linux"] +tags: + - git + - server + - setup + - howto + - do it yourself + - ssh +categories: + - code + - diy + - linux --- Hello everyone, @@ -32,16 +41,16 @@ Installing a git server is quite simple once you know how it works, on my server I've added a new user and group to my server but before doing so I added /usr/bin/git-shell to /etc/shells in order to use it as login shell for my git user. -``` +{{< highlight bash >}} echo "/usr/bin/git-shell" >> /etc/shells groupadd git mkdir /var/git useradd -d /var/git -g git -M -s /usr/bin/git-shell -``` +{{< /highlight >}} now the user is all set and ready to be used. Next step will be to create the .ssh directory and the authorized_keys file to hold the keys for the developers that have to access the git server. Here's how I did it: -``` +```bash mkdir /var/git/.ssh touch /var/git/.ssh/authorized_keys chown -R git:git /var/git @@ -55,7 +64,7 @@ Let's head back to my working computer, I created an ssh keypair for my usual us Since I have ssh access to the same server for my normal user I used the ~/.ssh/config file on my computer to set a new host that will ease my access routine for the git user as well as my regular user, that's my config (more or less): -``` +```bash cat ~/.ssh/config Host regular_ssh HostName server.tld @@ -80,7 +89,7 @@ and ssh will take care of all the options and start the connection with the corr Now that the access for the git user is setup we have one last thing to do before being able to use it. We'll give him only limited commands to use, That way the git user will be even more limited and much more secure. Inside the documentation shipped with git there's a lot of scripts to get you started with this, so we'll copy them inside a special directory called git-shell-commands, like this: -``` +```bash cp -R /usr/doc/git-2.14.4/contrib/git-shell-commands /var/git chown -R git:git /var/git @@ -88,7 +97,7 @@ chown -R git:git /var/git Now we have 2 commands inside the git-shell-commands directory, list and help, the first will show all projects inside the /var/git directory and the other will show a simple help text and a list of all the commands available. Now to give you an example of how easy it is to add commands to the git-shell I will create a simple command that acts as the clear command, it will clean the screen, to do so, from inside the /var/git directory I did: -``` +```bash echo $(which clear) > git-shell-commands/clear chmod 0755 git-shell-commands/clear @@ -102,7 +111,8 @@ Let's focus on the two most important scripts for our git server, the **create** ### create -
#! /bin/bash
+{{< highlight bash "linenos=table" >}}
+#! /bin/bash
 
 # usage:        create  - create a git bare repository named PROJECT.git
 #               this command will setup the repo and send a mail for confirmation.
@@ -233,7 +243,8 @@ else
                                 ;;
                 esac
         fi
-fi
+fi +{{< /highlight >}} This is the create script, as you can see it's a bit complex because it will do a few things for me: @@ -246,15 +257,18 @@ This is the create script, as you can see it's a bit complex because it will do So after saving this script as create inside the git-shell-commands directory, we'll give it executable permissions and we can move to the delete script. -
# cat create-bare-repo.sh > /var/git/git-shell-commands/create
-# chown git:git -R /var/git/git-shell-commands
-# chmod 0755 /var/git/git-shell-commands/create
+{{< highlight bash >}} +cat create-bare-repo.sh > /var/git/git-shell-commands/create +chown git:git -R /var/git/git-shell-commands +chmod 0755 /var/git/git-shell-commands/create +{{< /highlight >}} ### delete Let's see the delete script: -
#! /bin/bash
+{{< highlight bash "linenos=table" >}}
+#! /bin/bash
 
 # usage:        delete  - PERMANENTLY delete a repository if existing.
 #               CAREFUL, this action cannot be undone. This command will ask for confirmation.
@@ -304,7 +318,8 @@ if [ -d ${GITDIR}/${PROJECT}.git ]; then
                 echo "\"${PROJECT}.git\" is an empty directory, Skipping. Check with your System Administrator."
                 exit 177
         fi
-fi
+fi +{{< /highlight >}} This script is much simpler than the previous one, it'll accept the name of the project as argument on the command line or will ask for it and will only delete it if it is a proper git repository, otherwise it will just exit with an error code. @@ -312,7 +327,8 @@ I improved the way those scripts recognise a git repository from simply relying Since we are here let's modify the help command to make it show a short description of every available command. -
#!/bin/sh
+{{< highlight bash "linenos=table" >}}
+#!/bin/sh
 
 # usage:        help - Lists all the available commands
 #               help  - Detailled explanation of how "command" works
@@ -342,11 +358,13 @@ else
                 *) [ -f "$cmd" ] && [ -x "$cmd" ] && echo "$cmd" ;;
                 esac
         done
-fi
+fi +{{< /highlight >}} The main thing I added is the support for a command line argument, now I'm able to run it by itself and display the usual output with a list of available commands, or followed by a command name to give a brief explanation like this: -
git> help
+{{< highlight bash >}}
+git> help
 Hi git, Run 'help' for help, 'help ' for specific help on a command, run 'exit' to exit. Available commands:
 clear
 create
@@ -356,7 +374,7 @@ git> help create
 usage:  create  - create a git bare repository named PROJECT.git
         this command will setup the repo and send a mail for confirmation.
 git>
-
+{{< /highlight >}} Pretty nice isn't it?! Now it's much more user friendly, and to show the description I used awk and cut to parse the comment at the top of every script I have in the `git-shell-commands` directory. @@ -368,18 +386,18 @@ In the next page we'll see the usual routine I follow when working with this new Let's say I had a new idea for a WordPress plugin, I can't wait to start writing, so the setup of the GIT environment should be as fast as possible. That's where my setup will come in handy. Let's open the terminal, I'll go inside my testing directory and from there I'll run: -
ssh git_ssh 'create awesomePlugin'
+{{< highlight bash >}}ssh git_ssh 'create awesomePlugin'
 creating project "awesomePlugin.git"
 Initialized empty Git repository in /var/git/awesomePlugin.git/
 All done, you can now work on "awesomePlugin.git"
-
+{{< /highlight >}} The project is created, now I just need to clone it -
git clone ssh://git_ssh:/var/git/awesomePLugin.git
+{{< highlight bash >}}git clone ssh://git_ssh:/var/git/awesomePLugin.git
 Cloning into 'awesomePlugin'...
 warning: Looks like you cloned an empty repository.
-
+{{< /highlight >}} And that's it, I now have a local and a remote copy of my git repository ready to work with. @@ -387,17 +405,17 @@ Let's say I'm working on this plugin and I get to the point where I feel like I Inside the deploy.sh script I'll edit those 2 lines: -
# Directory where to deploy files from repository
+{{< highlight bash >}}# Directory where to deploy files from repository
 DPTARGET=""
 # Branch that is going to be deployed to server
 DPBRANCH="master"
-
+{{< /highlight >}} adding `/var/www/wp-content/plugins/awesomePlugin` as `DPTARGET` and production as `DPBRANCH`. now on my local system I'll add a new branch and use that before committing my stable code. -
git checkout -b production
+{{< highlight bash >}}git checkout -b production
 Switched to a new branch 'production'
 
 git add .
@@ -420,7 +438,7 @@ remote:    | Tag name     : release_12072018-1110
 remote:    \==============================
 To ssh://git_ssh:/var/git/awesomePlugin.git
  * [new branch]      production -> production
-
+{{< /highlight >}} And that's it, now my new plugin is ready to go live as soon as I activate it inside my WordPress admin area. diff --git a/content/is/_index.md b/content/is/_index.md index 62cd10d..1a4806a 100644 --- a/content/is/_index.md +++ b/content/is/_index.md @@ -11,7 +11,7 @@ Mi sento: - "allegro ma un po' stanco" --- -{{< gravatar mail="danixland@gmail.com" class="alignright" size=200 >}} +{{< gravatar mail="danixland@gmail.com" class="image right circle" size=250 >}} Welcome to danix.xyz, my name is Danilo but you can call me danix. @@ -19,4 +19,6 @@ What is this website? Well, **danix.xyz** is my personal website, in here you ca I use this website to keep track of all the snippets of code that I tend to forget, I consider this website like my notepad (in the hope that it can turn useful to somebody else). -I deeply dislike sharing readers data with other companies so you can be sure that **all** the data I collect from my readers will be kept secure and used only to improve the way my readers enjoy the pages and posts I write. Read more about [my Privacy Policy]({{< ref "legal" >}} "Privacy Policy here at danix.xyz"). +I deeply dislike sharing readers data with other companies so you can be sure that I don't collect any data from my readers. I've setup hugo not to track my readers and to instruct other sites referenced on my pages to do so as well. + +Read more about [my Privacy Policy]({{< ref "legal" >}} "Privacy Policy here at danix.xyz"). -- 2.20.1