Tag Archives: Work

http ri mu

Tagged

fix of the day Drupal stores extra php…

fix of the day:
Drupal stores extra php configuration (like memory_limit) in sites/default/settings.php
Drush is your friend!

Similar Posts:

Tagged , , , ,

Tweaking GitLab Setup

What?

GitLab is your own GitHub and more (or less). They have pretty good introduction on the home page, so I won’t repeat that here.

The recommended installation method for GitLab is using the Omnibus package. Head to the downloads page and follow the instructions. You should have a GitLab setup in no time, who needs GitHub! oh well, many many people…

Now to the tweaks.

Why?

If you’re like me trying to hide the ports on your server from the bots and prying eyes, they you would have SSH on a different port and your other services all bound to localhost and facing the Internet bravely from behind a proxy server. I use Apache on my personal server, it’s pretty robust and gets the job done.

So let’s say SSH is on port 2022, and apache is taking firm hold on ports 80 and 443. So GitLab’s NGINX should take port 8088.

And the domain you’re using for gitlab is not the machine’s hostname, so hostname is ‘host4339.moodeef.com’ and gitlab’s URL is ‘gitlab.deeb.me’

How?

Edit the “/etc/gitlab/gitlab.rb” file with the following changes/additions:

gitlab_rails['gitlab_host'] = 'gitlab.deeb.me'
gitlab_rails['gitlab_ssh_host'] = 'gitlab.deeb.me'
gitlab_rails['gitlab_port'] = 8088
gitlab_rails['gitlab_email_from'] = 'git-no-reply@deeb.me'
gitlab_rails['gitlab_support_email'] = 'git-no-reply@deeb.me'
gitlab_rails['gitlab_shell_ssh_port'] = 2022
external_url = 'https://gitlab.deeb.me'

Then run gitlab-ctl reconfigure and see how it goes from there.

If things seem to be too complicated, you can always get a subscription option with full support from the GitLab folks. Or hire me to fix it for you!

Similar Posts:

Tagged , , , , ,

Quickly Start a Django Project

There are many things I like to do when starting a django project. I started to compile those in a script I’m using. The gist is linked below.

New Django Project.sh

#!/bin/bash
# 
# Author: Abdallah Deeb 
# Requirements: python, pip, virtualenv, virutalenvwrapper, git
#
# Edit the following 2 lines
PROJECTNAME=proj
APPNAME=myapp
if [ -n "$2" ]
then 
  APPNAME="$2"
fi
if [ -n "$1" ]
then 
  PROJECTNAME=$1
fi

source `which virtualenvwrapper.sh` 

echo "Starting a new Django project: $PROJECTNAME"
# Make a virtualenv
mkvirtualenv $PROJECTNAME

# Install latest django and start the project/app
pip install django
django-admin.py startproject $PROJECTNAME
cd $PROJECTNAME
django-admin.py startapp $APPNAME
mv $PROJECTNAME conf

# conf is much nicer than projname
replace $PROJECTNAME conf -- manage.py conf/settings.py conf/wsgi.py conf/urls.py
chmod +x manage.py
workon $PROJECTNAME

# Initialize and use git
git init
git add .
git commit -a -m 'initial commit'

and the raw gist download

Similar Posts:

Tagged , , , ,

Drush in Jail Shell

I am not a drupal expert.
We got a request from a customer today asking to install drush in a jailed shell so that the user would only be able to run drush, but use it to do everything. Or at least this is how I understood the task.

Installing drush on CentOS (as root):

yum install php-pear
pear channel-discover pear.drush.org
pear install drush/drush

Do I need jailkit?
Here’s how to install jailkit:

yum install gcc make
wget -c http://olivier.sessink.nl/jailkit/jailkit-2.15.tar.bz2
tar xf jailkit-*.tar.bz2
cd jailkit-*
./configure
make
make install

The jailkit configuration files are in /etc/jailkit/

Jailing drush is in fact about jailing php-cli (or just php depending on your distro).

Turns out no scripts are needed (other than jailkit). I added the following to /etc/jailkit/jk_init.ini

[php]
comment = PHP and libs
paths = php
users = root, www-data, phpjtest
groups = root, www-data

[drush]
comment = Drupal Shell
paths = /usr/bin/drush, /usr/share/drush, /etc/drush
includesections = php

And ran:

mkdir /srv/jail
chown root:root /srv/jail
chmod 0755 /srv/jail
jk_init -j /srv/jail jk_lsh
jk_init -j /srv/jail drush
adduser phpjtest
jk_jailuser -v -m -j /srv/jail phpjtest

Now to setup the drush alias:

mkdir ~/.drush/ # if not already there
vi ~/.drush/aliases.drushrc.php

with the following contents:

 'stage.example.com',
  'root' => '/var/www/example.com',
  'remote-host' => 'remote.host.ip.or.name',
  'remote-user' => 'phpjtest',
);
?>

Next, set up a passwordless login to the remote server using:

# this is done on the client side (home pc)
ssh-keygen -t rsa
ssh-copy-id phpjtest@remote.host.ip.or.name 

And you should be able to run drush commands from the local machine using:
drush @remote1 status

Going to test this shortly…

Similar Posts:

Tagged , , , , , ,

Table ‘mysql.servers’ doesn’t exist

That’s a bit confusing, but mainly all you need to do is:
mysql_upgrade

Or if there’s a password on the admin account:
mysql_upgrade -u admin -p

Similar Posts:

Tagged , ,

YUI DataTable not refreshing in IE

IE is very annoying when it comes to JavaScript code. But that’s for another entry.

For now, I just learned that my code that refreshes the YUI DataTable will not work unless I stop the caching. I added the following code:

var refreshDataTable = function() {
            myDataTable.showTableMessage("Loading...");
            var currentState = History.getCurrentState("myDataTable");
            currentState = currentState + "&d="+new Date().getTime();
            handleHistoryNavigation(currentState);            
        };

Similar Posts:

Tagged , , ,