<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>bash — LowEndSpirit</title>
        <link>https://lowendspirit.com/index.php?p=/</link>
        <pubDate>Thu, 04 Jun 2026 01:02:56 +0000</pubDate>
        <language>en</language>
            <description>bash — LowEndSpirit</description>
    <atom:link href="https://lowendspirit.com/index.php?p=/discussions/tagged/bash/feed.rss" rel="self" type="application/rss+xml"/>
    <item>
        <title>A Bash Script to Auto Renew Minio SSL</title>
        <link>https://lowendspirit.com/index.php?p=/discussion/6499/a-bash-script-to-auto-renew-minio-ssl</link>
        <pubDate>Wed, 20 Sep 2023 04:46:04 +0000</pubDate>
        <category>Technical</category>
        <dc:creator>cloudpap</dc:creator>
        <guid isPermaLink="false">6499@/index.php?p=/discussions</guid>
        <description><![CDATA[<p>Hello everyone,</p>

<p>I wrote a script using bash to help renew lets encrypt ssl issued using on a minio instance. Minio is an s3 compatible storage. Basically, the ssl is issued via certbot but files need to be moved around. I found myself every now and then having my minio ssl expired and I didn't know. so i created this script to check daily when the hostname ssl expires and to renew it automatically. hope it helps someone with a similar need.</p>

<pre><code>#!/bin/bash
PUSHOVER_API_TOKEN='xxxxx'
PUSHOVER_API_USER='xxxx'

HOSTNAME=$(hostname)


DEFAULT_PRIVATEKEY_LOCATION=/etc/letsencrypt/live/$HOSTNAME/privkey.pem
DEFAULT_CERTIFICATE_LOCATION=/etc/letsencrypt/live/$HOSTNAME/fullchain.pem

MINIO_USERNAME=minio-user
MINIO_PRIVATEKEY_LOCATION=/etc/minio/certs/private.key
MINIO_CERTIFICATE_LOCATION=/etc/minio/certs/public.crt


certexpiredays(){
    EXPIREDATE=$(openssl x509 -in $MINIO_CERTIFICATE_LOCATION -enddate -noout | sed "s/.*=\(.*\)/\1/")
    EXPIRE_DATE_IN_SECONDS=$(date -d "${EXPIREDATE}" +%s)
    NOW_IN_SECONDS=$(date -d now +%s)
    DATE_DIFF_IN_SECONDS=$(( (EXPIRE_DATE_IN_SECONDS - NOW_IN_SECONDS) / 86400 ))

    echo $DATE_DIFF_IN_SECONDS
}


notify(){
    STATUS=$1

    local TITLE="Renewal of Minio SSL"
    if [[  $STATUS -eq 0  ]]
    then
        local MESSAGE="SUCCESS! Minio SSL successfully replenished for https://$HOSTNAME:9000"
    else
        local MESSAGE="FAILED! Could not complete SSL renewal for minio. Status code: $STATUS for https://$HOSTNAME:9000"
    fi
    local SOUND=siren
    local TIME=$(date)
    local PRIORITY=0
    curl -s \
      --form-string "token=$PUSHOVER_API_TOKEN" \
      --form-string "user=$PUSHOVER_API_USER" \
      --form-string "title=$TITLE" \
      --form-string "message=$MESSAGE" \
      --form-string "timestamp=$TIME" \
      --form-string "sound=$SOUND" \
      --form-string "priority=$PRIORITY" \
      https://api.pushover.net/1/messages.json
}


#0.Check if renewal is needed in the first place

DAYS_TO_SSL_EXPIRY=$(certexpiredays)


if [[ (( $DAYS_TO_SSL_EXPIRY &lt; 5 ))]]
then
    #1.Renew SSL
    echo "===Commencing SSL renewal...==="

    echo 2 | sudo certbot certonly --standalone -d $HOSTNAME

    if [ $? -eq 0 ]
    then
        echo "==&gt;OK! SSL for minio has been requested successfully."
        echo "==&gt;Copying SSL files...."

        #2. Copy SSL files to correct directory
        sudo cp -v $DEFAULT_PRIVATEKEY_LOCATION $MINIO_PRIVATEKEY_LOCATION
        sudo cp -v $DEFAULT_CERTIFICATE_LOCATION $MINIO_CERTIFICATE_LOCATION

        if [ $? -eq 0 ]
        then
            echo "==&gt;OK! SSL files copied successfully..."

            #3. Change ownership of the SSLs
            sudo chown $MINIO_USERNAME:$MINIO_USERNAME $MINIO_PRIVATEKEY_LOCATION
            sudo chown $MINIO_USERNAME:$MINIO_USERNAME $MINIO_CERTIFICATE_LOCATION

            if [ $? -eq 0 ]
            then
                #4. Restart minio service
                sudo systemctl restart minio

                pgrep minio &gt;/dev/null 2&gt;&amp;1
                STATE=$(echo $?)

                if [[  $STATE == 0  ]]
                then
                    echo "==&gt;OK! Minio restarted successfully..."

                    echo "==&gt;SUCCESS! SSL for minio replenished successfully."
                    notify 0
                else
                    echo "==&gt;FAILED! Could not restart minio."
                    notify 1
                    exit
                fi
            fi
        else
            echo "==&gt;FAILED! There was an error copying SSL files."
            notify 2
            exit
        fi

    else
        echo "==&gt;FAILED! There was an error requesting for SSL for minio."
        notify 3
        exit
    fi
else
    echo "==&gt;SSL for minio still valid for $DAYS_TO_SSL_EXPIRY days. Nothing to do. Bye"
    exit
fi
</code></pre>
]]>
        </description>
    </item>
    <item>
        <title>jq headache</title>
        <link>https://lowendspirit.com/index.php?p=/discussion/4664/jq-headache</link>
        <pubDate>Sat, 01 Oct 2022 09:50:44 +0000</pubDate>
        <category>Help</category>
        <dc:creator>legendary</dc:creator>
        <guid isPermaLink="false">4664@/index.php?p=/discussions</guid>
        <description><![CDATA[<p>Have this structure of JSON:</p>

<pre><code>(
    [0] =&gt; stdClass Object
        (
            [create_user] =&gt; Array
                (
                    [0] =&gt; stdClass Object
                        (
                            [time] =&gt; 2022-10-01_12:43:05
                            [level] =&gt; success
                            [message] =&gt; Username created: xbnitapwr
                        )

                )

        )

    [1] =&gt; stdClass Object
        (
            [create_user] =&gt; Array
                (
                    [0] =&gt; stdClass Object
                        (
                            [time] =&gt; 2022-10-01_12:43:05
                            [level] =&gt; success
                            [message] =&gt; User modified: xbnitapwr
                        )

                )

        )

)
</code></pre>

<p>I need to make it like this:</p>

<pre><code>(
    [0] =&gt; stdClass Object
        (
            [create_user] =&gt; Array
                (
                    [0] =&gt; stdClass Object
                        (
                            [time] =&gt; 2022-10-01_12:43:05
                            [level] =&gt; success
                            [message] =&gt; Username created: xbnitapwr
                        )
                    [1] =&gt; stdClass Object
                        (
                            [time] =&gt; 2022-10-01_12:43:05
                            [level] =&gt; success
                            [message] =&gt; User modified: xbnitapwr
                        )
                )
        )
)
</code></pre>

<p>TL;DR: I need to group elements by create_user key. And this is in bash env with jq. Any suggestions?</p>
]]>
        </description>
    </item>
    <item>
        <title>Data to S3 - google or s3 which one is cheapest?</title>
        <link>https://lowendspirit.com/index.php?p=/discussion/1067/data-to-s3-google-or-s3-which-one-is-cheapest</link>
        <pubDate>Mon, 18 May 2020 08:28:59 +0000</pubDate>
        <category>General</category>
        <dc:creator>verjin</dc:creator>
        <guid isPermaLink="false">1067@/index.php?p=/discussions</guid>
        <description><![CDATA[<p>Looking for bash script/sotfware or anything which can transfer data from Google Drive (2TB) to S3 storage. In short, with automation.</p>

<p>Another question: Google Drive (2TB, $10/month) or AWS-S3 (2TB) (which one is cheapest)</p>

<p>Please recommend and give your suggestions.</p>
]]>
        </description>
    </item>
   </channel>
</rss>
