Category: filethingie

Update Second Crack from filethingie

This blog post describes how to set up a filethingie installation and create a plugin to update your posts. It assumes that you already have a shell script in place to start the update of your blog.

Disclaimer: you are yourself responsible for securing the access to filethingie and the command to update secondcrack.
For the first step simply point the filethingie basepath to the second crack basepath. I use:

/srv/http/webapps/siteroot
- cache
- drafts
- htdocs
    filethingie
- media
- pages
- posts
- secondcrack
- templates
update.sh

In the filethingie config.php I have set the basepath to:

$ft["settings"]["DIR"]               = "../.."; // Your default directory.  Do NOT include a trailing slash!

From there I can manage all the folders and upload new files.

Files to create/update to update Second Crack

plugins/secondcrack.plugin.php

When in the filethingie root, create plugins/secondcrack.plugin.php

<?php
function ft_secondcrack_info() {
    return array(
        'name' => 'Secondcrack pugin',
        'settings' => array(
            'updatecommand' => array('description' => 'The command to update the blog', 'default' => '')
        )
    );
}

function ft_secondcrack_page($act) {
    global $ft;
    if ($act === 'secondcrack') {
        set_time_limit(0);
        $command = $ft['plugins']['secondcrack']['settings']['updatecommand'];
        $result = shell_exec($command);
        return 'Command run! Output: <i>' . htmlentities($result) . '</i>';
    }
}

function ft_secondcrack_secondary_menu() {
    return '<a href="' . ft_get_self() . '?act=secondcrack">Update Secondcrack</a>';
}

config.php

$ft['plugins']['secondcrack'] = array(
'settings' => array('updatecommand' => '[the updatecomand]')
);

Replace [the updatecommand] with the command you use to update secondcrack. I have created a small update.sh shell script that I placed in the root of the folder.

update.sh

#!/bin/sh

cd /srv/http/webapps/siteroot
/usr/bin/php ./secondcrack/engine/update.php >> /var/log/secondcrack.log 2>&1

echo "CLI: Executed update command for secondcrack."

This script assumes that there is a folder called secondcrack in the siteroot where the engine can be invoked.

Leave a Comment