Skip to content

How to upgrade nextcloud from gui to next major version

So, nextcloud version 15.0.x is out already and whenever you are logging into your next cloud with your administrator account, you still get this "you are on the latest version" message.

Further more, you just got a update to version 14.0.x while waiting for version 15.0.x.

To fix this, all you have to do is to switch from the channel "stable" to "beta". After a page reload, you should see a version 15.0.x available. Do the upgrade and do not forget to switch back to the stable channel.

Translate to de es fr it pt ja

It just happens on my Rasperry pi: signature from "Arch Linux ARM Build System <[email protected]>" is unknown trust

I've started a regular update by using sudo pacman -Syyu and the following lines where the final result.

warning: Public keyring not found; have you run 'pacman-key --init'?
downloading required keys...
error: key "77193F152BDBE6A6" could not be looked up remotely
error: required key missing from keyring
error: failed to commit transaction (unexpected error)
Errors occurred, no packages were upgraded.

I did what was told me to do ;-).

sudo pacman-key --init

And after running sudo pacman -Syyu I was asked.

:: Import PGP key 4096R/68B3537F39A313B3E574D06777193F152BDBE6A6, "Arch Linux ARM Build System <[email protected]>", created: 2014-01-18? [Y/n]

"As expected, I though" but than I got a long list of the error mention in the headline (for each package).

I've fixed this by executing the following command.

pacman-key --lsign-key 77193F152BDBE6A6

After that, sudo pacman -Syyu was running fine as expected. Strange note, all was working fine a week ago (2018-05-25) and the pgp key was created 2014 :-O.

Translate to de es fr it pt ja
Categories: os
Defined tags for this entry: , , ,
Vote for articles fresher than 7 days!
[0] 368 hits

JDownloader and spontaneous core dump

JDownloader was working properly and than you just get core dumps all over again? Best try, upgrade your Java Runtime Environment.

sudo archlinux-java status
sudo pacman -S jre9-openjdk
sudo archlinux-java set jre9-openjdk
#if not needed anymore
sudo pacman -R jre8-openjdk

You need to update the $PATH variable. Either you restart your system or you open a new terminal to start JDownloader from their. All should work fine now.

Translate to de es fr it pt ja
Categories: os
Defined tags for this entry: , ,
Vote for articles fresher than 7 days!
Derzeitige Beurteilung: 1 of 5, 21 Stimme(n) 494 hits

nextcloud upgrade 13 - how to upgrade from nextcloud 12 to 13

I am doing all via the command line. I've a separate data directory (not included below public/data).

Here are my simple steps (database backup not included). I did the upgrade from the latest 12 release. This is a KISS tutorial.

cd <root path>
wget "https://download.nextcloud.com/server/releases/nextcloud-13.0.0.zip"
unzip nextcloud-13.0.0.zip
mv public public_12_0_5
mv nextcloud public
cp public_12_0_5/config/config.php public/config/config.php
rsync -rv --dry-run public_12_0_5/apps public/apps
#if needed
#rsync -rv public_12_0_5/apps public/apps

Good luck on your side.

Currently, I've found one issue with my news application.

I needed to execute following SQL statement:

UPDATE oc_jobs SET reserved_at = 0 WHERE (argument = '["OCA\\News\\Cron\\Updater","run"]' OR class = 'OCA\\News\\Cron\\Updater');

Thanks to the how to fix it section.

Translate to de es fr it pt ja
Categories: others
Defined tags for this entry: ,
Vote for articles fresher than 7 days!
Derzeitige Beurteilung: 1 of 5, 6 Stimme(n) 2240 hits

quick one, output the license for each composer.json project within a root path

A quick one since I have to alligne all my open source packages to theSPDX License List. To list all available licenses from my root path, I've quickly written this one liner.

find . -maxdepth 2 -name composer.json -type f -exec grep -i -H license {} \;

Boy, to write this one liner without having a look to one man-page took me ... well, ages.

Translate to de es fr it pt ja
Categories: coding
Defined tags for this entry: , , ,
Vote for articles fresher than 7 days!
Derzeitige Beurteilung: 1 of 5, 3 Stimme(n) 1214 hits

arch linux error: key "CEB167EFB5722BD6" could not be looked up remotely

On some machines, I get the following error when I run an "pacman -Syyu".

error: key "CEB167EFB5722BD6" could not be looked up remotely

I've found the best fox so far on this page.

#open /etc/pacman.d/gnupg/gpg.conf as root
#comment out existing server address and replace with following
#save the file afterwards
http://pool.sks-keyservers.net

#run following command as root
pacman-key --refresh-keys

#if the upgrade is still not working, signed the key (be aware to know what you are doing here!)
pacman-key --lsign-key CEB167EFB5722BD6

This was working on almost all machines. Only a few percent where still not able to be upgraded. What I did to fix this issue was to copy the the directory in "/etc/pacman.d/gnupg" from a working host to the not working one (make a backup first of course).

Translate to de es fr it pt ja
Categories: os
Defined tags for this entry: , ,
Vote for articles fresher than 7 days!
[-2] 2604 hits

Ocramius ProxyManager or the great library that does the heavy lazy loading lifting for you

Within the next few lines, I will show you how you can use the proxy manager and how low the setup fee is compared to self written code.

The setup fee

Give is, that you have installed the ProxyManager with Composer. Than, create a script like the following (I will name it foo.php because I like it ;-)).

<?php
/**
 * @author stev leibelt <[email protected]>
 * @since 2017-12-12
 */

require_once __DIR__ . '/vendor/autoload.php';

use ProxyManager\Factory\LazyLoadingValueHolderFactory;
use ProxyManager\Configuration;

$configuration = new Configuration();
$configuration->setProxiesTargetDir(
    __DIR__ . '/../cache'
);

spl_autoload_register(
    $configuration->getProxyAutoloader()
);

class A
{
    /** @var mixed */
    private $foo;

    public function __construct(
        $foo
    ) {
        echo __METHOD__ . PHP_EOL;
        echo 'Something will take very long.' . PHP_EOL;
        sleep(5);
        $this->foo = $foo;
        echo 'Done.' . PHP_EOL;
    }

    public function __call($name, $arguments)
    {
        echo __METHOD__ . sprintf(
            'name: >>%s<<, list of arguments: >>%s<<.',
            $name,
            implode(
                ',',
                $arguments
            )
        ) . PHP_EOL;
    }

    public function foo()
    {
        echo $this->foo . PHP_EOL;
    }
}

class B extends A
{
    /** @var mixed */
    private $constructorFoo;

    /** @var bool */
    private $isNotInstantiated;

    public function __construct(
        $foo
    ) {
        echo __METHOD__ . PHP_EOL;
        echo 'Superfast.' . PHP_EOL;
        $this->constructorFoo       = $foo;
        $this->isNotInstantiated    = true;
        echo 'Done.' . PHP_EOL;
    }

    public function __call($name, $arguments)
    {
        $this->instantiateIfNeeded();

        parent::__call($name, $arguments); // TODO: Change the autogenerated stub
    }

    public function foo()
    {
        $this->instantiateIfNeeded();

        parent::foo(); // TODO: Change the autogenerated stub
    }

    private function instantiateIfNeeded()
    {
        if ($this->isNotInstantiated) {
            parent::__construct(
                $this->constructorFoo
            );

            $this->isNotInstantiated = false;
        }
    }
}

echo ':: Construct A' . PHP_EOL;
$a = new A('a');
echo ':: Construct B' . PHP_EOL;
$b = new B('b');
echo ':: Construct C' . PHP_EOL;
$factory = new LazyLoadingValueHolderFactory(
    $configuration
);
$c = $factory->createProxy(
    A::class,
    function (&amp; $wrappedObject, $proxy, $method, $parameters, &amp; $initializer) {
        $wrappedObject = new A('c'); // instantiation logic here
        $initializer   = null; // turning off further lazy initialization
    }
);

echo ':: Begin A' . PHP_EOL;
$a->foo();
$a->bar('foo', 'bar', 'baz');
echo ':: End A' . PHP_EOL;

echo ':: Begin B' . PHP_EOL;
$b->foo();
$b->bar('foo', 'bar', 'baz');
echo ':: End B' . PHP_EOL;

echo ':: Begin C' . PHP_EOL;
$c->foo();
$c->bar('foo', 'bar', 'baz');
echo ':: End C' . PHP_EOL;

And finally, execute it (clear && php foo.php).

What have we done - the explanation of the script

First, we are creating a class "A" that does some complicated stuff. Than, we are trying to implement our own lazy loading logic by creating a class "B". Afterwards we are instantiating A, B and A with the proxy manager. Finally, we are calling two methods for each instantiation.

When you execute the script, you quickly will figure out that the instantiation of $a is taking as long as expected while $b and $c are almost instantly there. At the end $b and $c will react the same.

Why should you use the proxy manager if you can archive the same stuff with "just some lines of code"? Because the proxy manager reduced your maintenance coast. If "A" would change, you would have need to extend or change "B" as well (e.g. A gets another method) while you don't have to touch any piece of code when using the proxy manager. Secondly, proxy manager is well tested and used. If you find an issue, you can fix it since the code is open source and do something good for the world - because sharing is caring.

Translate to de es fr it pt ja
Categories: coding
Defined tags for this entry: , , ,
Vote for articles fresher than 7 days!
Derzeitige Beurteilung: 2 of 5, 2 Stimme(n) 748 hits

Migrate all branches and tags to bitbucket/github/gitlab/other remote endpoint

To have a real world scenario think about the task to migrate from an existing private gitweb repository to bitbucket, with all tags and branches.

The solution simple und just needs some time if the repository is a bigger one.

First, you have to create an empty and new repository at bitbucket.

cd <path you want to do this action>
#the next step is just for safety reasons
mkdir <repository_name>
git clone --mirror [email protected]<your host>:<repository_name>.git .
git push --mirror [email protected]:<user_name>/<repository_name>

See how easy it is? Why not write a simple bash script?

#!/bin/bash
####
# @link https://artodeto.bazzline.net/archives/19519-Migrate-all-branches-and-tags-to-bitbucketgithubgitlabother-remote-endpoint.html
# @since 2017-11-06
# @author stev leibelt <[email protected]>
####

if [[ $# -lt 2 ]];
then
    echo ":: Invalid arguments provided."
    echo "   <command> \"<source repository url>\" \"<destination repository url>\""

    exit 1;
fi

DESTINATION_REPOSITORY_PATH="${2}"
SOURCE_REPOSITORY_PATH="${1}"
TEMPORARY_DIRECTORY="migrate_git_branch"

echo ":: Creating temporary directory."
mkdir "${TEMPORARY_DIRECTORY}"

cd "${TEMPORARY_DIRECTORY}"

echo ":: Cloning from source repository.".
git clone --mirror "${SOURCE_REPOSITORY_PATH}" .

echo ":: Pushing to destination repository."
git push --mirror "${DESTINATION_REPOSITORY_PATH}"

echo ":: You have to remove the following temporary directory if you want to."
echo "   "$(pwd)
Translate to de es fr it pt ja

How to update your arch linux without the kernel

If you are using archzfs and the zfsonlinux, you know that it can happen from time to time that you have to wait until packages are updated to the newest kernel (or lts kernel). Whenever you want to upgrade your system, you get an error like the following.

:: Starting full system upgrade...
resolving dependencies...
looking for conflicting packages...
error: failed to prepare transaction (could not satisfy dependencies)
:: spl-linux-lts: installing linux-lts (4.9.32-1) breaks dependency 'linux-lts=4.9.30'
:: zfs-linux-lts: installing linux-lts (4.9.32-1) breaks dependency 'linux-lts=4.9.30'
:: zfs-utils-linux-lts: installing linux-lts (4.9.32-1) breaks dependency 'linux-lts=4.9.30'

To update your system without the kernel (and its dependencies), you can use the following trick.

#example if you use the lts kernel
#if you use plain pacman
pacman -Syyu --ignore=linux-lts,linux-lts-headers
#if you use pacaur
pacaur pacman -Syyu --ignore=linux-lts,linux-lts-headers

Thats it :-).

Translate to de es fr it pt ja

Die IKEA Hotline und wie ich am Computer vorbei zu einem echten Berater gekommen bin.

IKEA bietet auf seinem Impressum und auch sonst überall nur eine Telefonnummer an, um mit ihnen in Kontakt zu treten. Es ist die "061 92 / 93 99999". Diese Nummer ist auch gern mal nicht verfügbar.

Wenn sie verfügbar ist, wird man von einem Computer empfangen. Die Spracherkennung ist eher so 1990 und auch sonst ist das Ding eher Marke "Weißglut" als Marke "Service". Im Vergleich zu anderen computergestützten Hotlines bringt einen das Fluchen hier nicht weiter. Was mich zu einem echten Berater gebracht hat waren die Worte "mit einer echten person sprechen". Viel gebracht hat es leider nicht, die Berater haben auch eher so Teilzeitwissen über das Sortiment oder über allgemeine Fragen zur Onlinebestellung.

Aktualisierung (11.02.2017)

Mit "scheiße, scheiße" kommt man auch an das Ziel zur echten Person. Wichtig, immer erst das Einrichtungshaus wählen.

Translate to de es fr it pt ja

disable automatic selected "Allow comments to this entry" for each entry in serendipity (s9y) blog system

For real, I was searching for this option for a year now and couldn't find an answer in a readme.

By disabling users in an other setup and restricting other users right, I found the magic checkbox I was searching for. Following the clickpath: Settings->Users->Edit User->Default settings for new entries->Allow comments to this entry Choose the radio button "no" and everything is working as expected :-).

Translate to de es fr it pt ja
Categories: others
Defined tags for this entry: ,
Vote for articles fresher than 7 days!
[0] 2957 hits

Zend Framework 2 - Lazy Factory - Kickstarter (for ZF 2.4)

No blabla, just how you do it with zend framework 2.4.

#add following line to your composer.json
"ocramius/proxy-manager": "1.0.*",

composer update

#add following lines to your module.config.php
'lazy_services' => [
    'class_map' => [
        \My\Class::class => \My\Class::class
    ]
],
'service_manager' => [
    'delegators' => [
        \My\Class::class => [
            \Zend\ServiceManager\Proxy\LazyServiceFactory::class
        ]
    ],
    'factories' => [
        \My\Class::class => \My\ClassFactory::class,
        \Zend\ServiceManager\Proxy\LazyServiceFactory::class => \Zend\ServiceManager\Proxy\LazyServiceFactoryFactory::class
    ]
]

Thats it.

Useful links are a gist from a closed issue and somehow an official howto (maybe working with zend framework greater 2.4).

Translate to de es fr it pt ja

X11 freezes and system total hang up on an Lenovo X250 i7-5600U since kernel 4.6.2 (arch linux)

Hey folks, since kernel 4.6.2 I got a lot of X11 freezes as well as unusable gui tools (delayed inputs, scrolling and broken display rendering). Also all the virtual box clients are behaving the same. Only the chromium gui and xterm were usable (well, xterm only on my host, not on the virtual box clients).
I tried my best and here are the changes I made that stopped the system from a total freeze since four days:

run as root

cat /etc/X11/xorg.conf.d/20-intel-graphics.conf < DELIM Section "Device" Identifier "Intel Graphics" Driver "intel" Option "AccelMethod" "uxa" Option "NoAccel" "True" EndSection DELIM

I am crossing fingers it is working on your machine also.

Translate to de es fr it pt ja

migration from owncloud 9 to nextcloud 9.0.50

I just migrated my installation from owncloud 9 to nextcloud 9.0.50.
Only one thing is not working, the notes application simple shows me an empty list of notes. beside that, it is more like a new theme.

At the moment we only support manual migrations from ownCloud 8.2 and 9.0 to Nextcloud 9.

To do that please follow the usual upgrading steps:

* Delete everything from the ownCloud folder except data and config
* Download the Nextcloud 9 release from https://nextcloud.com/install/43
* Put the files into the folder where the ownCloud files where before
* Trigger the update either via OCC or via web.

source

I did the following steps.

make a backup of your database

log into your server and cd to the owncloud path

#

assuming your installation is in the directory "cloud"

./occ maintenance:repair cd .. wget https://download.nextcloud.com/server/releases/nextcloud-9.0.50.zip unzip nextcloud-9.0.50.zip cp -rv cloud/config nextcloud/ cp -rv cloud/data nextcloud/ mv cloud owncloud mv nextcloud cloud cd cloud ./occ upgrade ./occ app:list

enable the apps you want

Update from 2016-06-26
I created a small upgrade.sh script. Here it is.

!/bin/bash

@author stev leibelt artodeto@bazzline.net

@since 2016-06-26

begin of runtime environment validation

if [[ $# -lt 1 ]]; then
echo "invalid number of variables provided"
echo "upgrade.sh "
exit 1
fi

if [[ -d backup ]]; then
echo "backup directory sill exists"
exit 1
fi

end of runtime environment validation

begin of local runtime variables

LOCALCURRENTDATE=$(date +'%Y-%m-%d')
LOCALURLTOTHENEXTVERSION="$1"
LOCAL
PUBLICBACKUPPATH="public$LOCALCURRENT_DATE"

end of local runtime variables

begin of downloading new version

wget $LOCALURLTOTHENEXT_VERSION
unzip *.zip

end of downloading new version

begin of making backups

cd public
tar --ignore-failed-read -zcf "public.$LOCALCURRENTDATE.tar.gz" public
./occ maintenance:singleuser --on
cd ../
mkdir backup
cp -rv public/config backup/
cp -rv public/data backup/
mv public $LOCALPUBLICBACKUP_PATH

end of making backups

begin of upgrade

mv nextcloud public
cp -rv backup/config public
cp -rv backup/data public
cd public
./occ upgrade
./occ maintenance:singleuser --off
echo "enable the apps you need with ./occ app:enable "
./occ app:list

end of upgrade

Translate to de es fr it pt ja

Propel, the PropelOnDemandFormatter, self loaded runtime properties and your special reload data if needed usecase- howto

Propel column representation offering the option to add some business logic inside. We are making this from time to time by enriching the existing object with more data, but only when a method is called explicit.


class MyTable extends BaseMyTable
{
    /** @var null|\My\Enriched\MyTable\Data */
    protected $enrichedData;

/**
 * @return null|\My\Enriched\MyTable\Data
 */
public function getEnrichedData()
{
    //prevent reloading enriched data if this method is called more than once
    if ($this->noEnrichedDataYetLoaded()) {
        //do something heavy data lifting
        $this->enrichedData = $this->tryToLoadEnrichedData();
    }

    return $this->enrichedData;
}

/**
 * @return bool
 */
private function noEnrichedDataYetLoaded()
{
    return (is_null($this->enrichedData));
}

}

If you would use the corrosponding MyTableQuery object in combination with a PropelOnDemandFormatter and iterating over an collection after calling find(), you would get the same enriched data for different MyTable objects.
Why? Because the PropelOnDemandFormatter does a smart thing by reusing the on MyTable object and "just" updating the properties.
Following is a workaround I am using to fix this (totally right) behaviour. Anyways, be caution if you do things like that. This should not be your regular way of doing it.


class MyTable extends BaseMyTable
{
    /** @var null|\My\Enriched\MyTable\Data */
    protected $enrichedData;

/** @var int */
protected $myId;

/**
 * @return null|\My\Enriched\MyTable\Data
 */
public function getEnrichedData()
{
    //prevent reloading enriched data if this method is called more than once
    if ($this->noEnrichedDataYetLoaded()) {
        //do something heavy data lifting
        $this->enrichedData = $this->tryToLoadEnrichedData();
        $this->myId         = $this->getId();
    }

    return $this->enrichedData;
}

/**
 * @return bool
 */
private function noEnrichedDataYetLoaded()
{
    return (
        ($this->myId == $this->getId())
        &&amp; (is_null($this->enrichedData))
    );
}

}

Translate to de es fr it pt ja

Reminder of the Propel Bug 734 - update() with limit() and a workaround

Just because we ran into this issue again. There is known and serious bug in propel whenever you use "update()" in combination with "limit()".
Our workaround right now is to replace the code.


//this will update all entry with the content "bar" in the column "foo"
MyQuery::create()
    ->filterByFoo('bar')
    ->limit(100)
    ->update(
        array(
            'Foo' => 'baz'
        )
    );

//this will only update 100 rows $ids = (array) MyQuery::create() ->filterByFoo('bar') ->limit(100) ->select( array( 'Id' ) ) ->find();

MyQuery::create() ->filterById($ids) ->update( array( 'Foo' => 'baz' ) );

Translate to de es fr it pt ja

howto - php composer - File(/etc/pki/tls/certs) is not within the allowed path(s) - on arch linux

Since a few days (or weeks?), I discovered the following issue on one of my Arch Linux system.
Whenever I try to use PHP's composer, I got the following issue:


[ErrorException]
is_dir(): open_basedir restriction in effect. File(/etc/pki/tls/certs) is not within the allowed path(s): (/srv/http/ [...]

Well, it didn't hurt that much since I am using (like every cool webkiddy is doing) docker or vagrant for my development. But this time, I needed to solve it since it is a customer edge case - so I solved it.
The how to I will show you is not the perfect way. I had two things in mind, try to minimize the place I have to adapt the php.ini. And try to keep the system as normal as possible. Until now, I can not estimate the security holes I opened with this setting. I will let you know if this how to turns out to be a "don't try this at home" thing.

So, what have I done?
First of all, I asked curl to tell me where it is looking for certificates by executing:


curl-config --ca

output: /etc/ssl/certs/ca-certificates.crt


After that I had a look what this path is:

ls -halt /etc/ssl/certs/ca-certificates.crt

output: [...] /etc/ssl/certs/ca-certificates.crt -> ../../ca-certificates/extracted/tls-ca-bundle.pem


So, with that knowledge it turned out that the following steps are reflecting my requirements mention above.

sudo mkdir -p /etc/pki/tls/certs
sudo ln -s /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-certificates.crt
sudo vi /etc/php/php.ini

add following lines to "open_basedir" configuration section

:/etc/pki/tls/certs:/etc/ssl/certs


And that is it, composer should now be back in business.

Translate to de es fr it pt ja

zf-rest - error "title":"Not Found","status":404,"detail":"Entity not found."

I configured the routes as well as the other parts pretty well.
An important step to solving the issue was adding the following configuration section into my project "local.php".


    //this is possible overwritten by the zf-rest module
    'view-manager' => array(
        'displayexceptions' => true,
        'displaynotfoundreason' => true
    )

After that, I got back an response with the following content:
{"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html","title":"Not Found","status":404,"detail":"Entity not found."

After adding a lot of debugging statements in the "ZF\Rest\RestController" (search for "Entity not found." ;-)), started understanding the issue.
The answer is pretty clear after all. Whenever you listen on a GET HTTP Method with your listener, you have to return an array with the configured "routeidentifiername" (the entity identifier), otherwise the controller as well as the HAL post processor is not able to successful build the response.

Translate to de es fr it pt ja

uberspace and let's encrypt

Nichts besonderes, ich habe einfach nur das Wissen aus dem wiki und dem blog genommen und ich ein shell script gepackt.

Das Resultat ist folgender Cronjob, der einmal aller 60 Tage läuft.

!/bin/bash -l

#

@see:

https://blog.uberspace.de/lets-encrypt-rollt-an/

https://wiki.uberspace.de/webserver:https?s[]=lets&s[]=encrypt

@author: stev leibelt <[email protected]>

@since: 2015-12-28

#

begin of local parameters

LOCALROOTPATH='/home/<user name>' LOCALLOGPATH=$LOCALROOTPATH'/<path to your log files>' LOCAL_ACCOUNT='<your.domain.tld>'

end of local parameters

begin of parameters for letsencrypt-renewer

LOCALCONFIGURATIONPATH=$LOCALROOTPATH'/.config/letsencrypt' LOCALLOGGINGPATH=$LOCALROOTPATH'/.config/letsencrypt/logs' LOCALWORINGPATH=$LOCALROOTPATH'/tmp/'

end of parameters for letsencrypt-renewer

begin of parameters for uperspace-prepare-certificate

LOCALKEYPATH=$LOCALROOTPATH'/.config/letsencrypt/live/'$LOCALACCOUNT'/privkey.pem' LOCALCERTIFICATEPATH=$LOCALROOTPATH'/.config/letsencrypt/live/'$LOCALACCOUNT'/cert.pem'

end of parameters for uperspace-prepare-certificate

letsencrypt-renewer --config-dir $LOCALCONFIGURATIONPATH --logs-dir $LOCALLOGGINGPATH --work-dir $LOCALWORINGPATH &>$LOCALLOGPATH uberspace-prepare-certificate -k $LOCALKEYPATH -c $LOCALCERTIFICATEPATH &>>$LOCALLOGPATH

In schön gibt es das script auch noch einmal hier.
Großen Dank an uberspace und lets encrypt.

Damit das script funktioniert, müsst ihr natürlich zu erst lets encrypt aufsetzen:


uberspace-letsencrypt 
letsencrypt certonly
Ich bin recht faul. Aus diesem Grund lass ich mir die Zertifikate einmal im Monat neu generieren. Um die Infrastruktur nicht zu sehr zu belasten, habe ich mir einen anderen Tag, als den Ersten im Monat ausgesucht. Das gleiche gilt für die Uhrzeit.

Translate to de es fr it pt ja

determine if an apache process is still running via bash to prevent multiple instances running

Given is the fact that you have some processes (like cronjobs) executed via an webserver like apache. Furthermore you have installed and enables apache server status. To add some re usability benefits, we should divide and conquer the problems into either shell scripts or shell functions. Side note, if I am writing about shell, I am in the bash environment. What are the problems we want to tackle down?:

  • find the correct environment
  • check all available webservers if a process is not running
  • specify which process should not run and start it if possible

We can put the first two problems into shell functions like the following ones. I am referencing to some self written shell functions. The reference is indicated by the "net_bazzline_" prefix.

#!/bin/bash
#find the correct environment

if net_bazzline_string_contains $HOSTNAME 'production';
    NET_BAZZLINE_IS_PRODUCTION_ENVIRONMENT=1
else
    NET_BAZZLINE_IS_PRODUCTION_ENVIRONMENT=0
fi

And the mighty check.

#!/bin/bash
#check all available webservers if a process is not running
####
# @param string <process name>
# @return int (0 if at least one process was found)
####
function local_is_there_at_least_one_apache_process_running()
{
    if [[ $# -lt 1 ]]; then
       echo 'invalid number of arguments'
       echo '    local_is_there_at_least_one_apache_process_running <process name>'

       return 1
    fi

    if [[ $NET_BAZZLINE_IS_PRODUCTION_ENVIRONMENT -eq 1 ]]; then
        LOCAL_ENVIRONMENT='production'
    else
        LOCAL_ENVIRONMENT='staging'
    fi

    #variables are prefixed with LOCAL_ to prevent overwriting system variables
    LOCAL_PROCESS_NAME="$1"

    #declare the array with all available host names
    declare -a LOCAL_HOSTNAMES=("webserver01" "webserver02" "webserver03");

    for LOCAL_HOSTNAME in ${LOCAL_HOSTNAMES[@]}; do
        APACHE_STATUS_URL="http://$LOCAL_HOSTNAME.my.domain/server-status"

        OUTPUT=$(curl -s $APACHE_STATUS_URL | grep -i $LOCAL_PROCESS_NAME)
        EXIT_CODE_OF_LAST_PROCESS="$?"

        if [[ $EXIT_CODE_OF_LAST_PROCESS == "0" ]]; then
            echo "$LOCAL_PROCESS_NAME found on $LOCAL_HOSTNAME"
            return 0
        fi
    done;

    return 1
}

And here is an example how to use it.

#!/bin/bash
#specify which process should not run and start it if possible

source /path/to/your/bash/functions

LOCAL_PROCESS_NAME="my_process"

local_is_there_at_least_one_apache_process_running $LOCAL_PROCESS_NAME

EXIT_CODE_OF_LAST_PROCESS="$?"

if [[ $EXIT_CODE_OF_LAST_PROCESS == "0" ]]; then
    echo "$LOCAL_PROCESS_NAME still running"
    exit 0;
else
    #execute your process
    echo 'started at: '$(date +'%Y-%m-%d %H:%M:%S');
    curl "my.domain/$LOCAL_PROCESS_NAME"
    echo 'started at: '$(date +'%Y-%m-%d %H:%M:%S');
fi

You can put this into a loop by calling it via the cronjob environment or use watch if you only need it from time to time:

watch -n 60 'bash /path/to/your/shell/script'

Enjoy your day :-).

Translate to de es fr it pt ja

Automatic setting of your multi display setting

So you have an X server running with multiple displays (or monitors).
You are using the great arandr tool to quickly setup your setting. But, you don't want to do this each time you are starting your X.
What can you do?
First of all, hit the "Save As" button in you arandr gui and store the shell script.
Afterwards, adapt the file that is read once you login into your system or start your X. This can be .xinit, .login or .profile.
Inside this file, simple add the adapted content from below and thats it.

maybe you have to change the path ".screenlayout" or the file name "default.sh"

if [ -f $HOME'/.screenlayout/default.sh' ]; then
. $HOME'/.screenlayout/default.sh'
fi

Translate to de es fr it pt ja

PHP DateInterval::__construct(): Unknown or bad format - trouble with ISO 8601 Date Format

To keep it short, you code is failing because of an message like:


DateInterval::__construct(): Unknown or bad format (P0Y2M7DT-1H7M14S) 
Why? Well it is obvious if your eyes are fresh, otherwise well hidden.
The bad thing is the "-" between "T" and "1". Cover your string by let it run through str_replace('-', '', $dateIntervalAsString) and you are a step closer to pretty safe code.
How can this happen?
First of all, by strange data and secondly by trying to solve the date format on your own. Really, old code is your enemy at this point.

For the sake of input and output, here are some important links:

Translate to de es fr it pt ja