Search This Blog

Tuesday, April 10, 2012

Headup Portage Tree

This portage tree is for apps that are not inside the official portage repository and some other packages with some hacks.
If you would like to contribute, report some bugs or send me suggestions, you can send me an email: alvaro[at]headup[dot]ws

Starting Points

How to configure Headup ebuilds

EBuilds

Saturday, April 7, 2012

[Solved] su: /bin/bash: Permission denied

New user created as:

groupadd mygroup useradd -s /bin/bash -g myuser -m -k /dev/null myuser

When trying to log in:

[root@vserver~]# su - myuser su: /bin/bash: Permission denied

Solution:

[root@vserver~]# chmod 755 /bin [root@vserver~]# su - myuser [myuser@vserver~]$

Thursday, April 5, 2012

Easy password generator command

 As a sysadmin, I need to generate lots of passwords and sometimes if you do so without a script the generated password becomes really easy to guess, and also is hard to build a safe password.

Because of this I use this script to generate pseudo-random passwords, is not an un-crackable method but solves the main problem.
You can put this code at the end of your .bashrc file, in order to make it like a system command, please do not remove the other lines in the file.

skyline ~ $ cd
skyline ~ $ vi .bashrc
##
##      By: Alvaro Soto - alvaro@headup.ws
##      http://headup.ws/node/18
##
##      genpasswd: Generate a pseudo random password
##                  using a given length (default = 20).
##

genpasswd() {
    local l=$1
        [ "$l" == "" ] && l=20
        tr -dc A-Z0-9_[%#?]a-z < /dev/urandom | head -c ${l} | xargs
}

##
##
##

skyline ~ $ . .bashrc
skyline ~ $ genpasswd 
vie8e4d5naTCH70XvDyT
skyline ~ $ genpasswd 10
ts0QtdPe_x
skyline ~ $ genpasswd 5
5nw5Q

Is a less secure option to pwgen but it doesn't need a compiler.

skyline ~ $ emerge pwgen -s Searching... [ Results for search key : pwgen ] [ Applications found : 1 ] * app-admin/pwgen Latest version available: 2.06-r1 Latest version installed: 2.06-r1 Size of files: 30 kB Homepage: http://sourceforge.net/projects/pwgen/ Description: Password Generator License: GPL-2
In action:

skyline ~ $ pwgen 20 --capitalize --symbols --numerals --secure 1 H2]}K/JGVs<523Xuv?"Y skyline ~ $ pwgen 10 --capitalize --symbols --numerals --secure 1 JZ7a*&|:RP skyline ~ $ pwgen 5 --capitalize --symbols --numerals --secure 1 `Aw8D

Sunday, March 4, 2012

Recursively delete .svn directories

Subversion is a software versioning and revision control system.
Every copy of source code received from the subversion repository has .svn folders, which store metadata.

This is a simple example of a Unix command, which recursively deletes subversion .svn folders, these folders are often not necessary if you want to distribute the source code.
You can put this code at the end of your .bashrc file, in order to make it like a system command, please do not remove the other lines in the file.

skyline ~ $ cd
skyline ~ $ vi .bashrc
##
##      By: Alvaro Soto - alvaro@headup.ws
##
##      csvn: Removes recursively all the .svn dirs 
##                  starting from a given path or from the cwd
##

csvn(){
    local dir=$1
        [ "$dir" == "" ] && dir=$(pwd)
        while true; do
            read -p "Do you wish to delete .svn dirs on [ $dir ]? " yn
            case $yn in
                [Yy]* ) find $dir -name .svn -print0 | xargs -0 rm -rf ; break;;
                [Nn]* ) break;;
                * ) echo "Please answer yes or no.";;
            esac
        done
}

##
##
##


Source and use

skyline ~ $ . .bashrc skyline ~ $ csvn Do you wish to delete .svn dirs on [ /Users/alvaro ]? n skyline ~ $

Thursday, December 22, 2011

Solving GCC Kernel error: ***mixed implicit and normal rules

I'm using an old kernel because is the last stable to use with the VServer patch.

evo src # ll
total 154344
lrwxrwxrwx  1 root root       15 Dec 22 20:07 linux -> linux-2.6.22.19
drwxrwxr-x 20 root root      840 Dec 22 20:07 linux-2.6.22.19
-rw-r--r--  1 root root 45108030 Nov 18  2009 linux-2.6.22.19.tar.bz2
-rw-r--r--  1 root root  1868800 Mar 17  2008 patch-2.6.22.19-vs2.2.0.7-grsec2.1.11-20080317.diff
evo linux # make
Makefile:1443: *** mixed implicit and normal rules.  Stop.
evo linux # make oldconfig
Makefile:1443: *** mixed implicit and normal rules.  Stop.
evo linux # vi Makefile 
.....
/ %/: prepare scripts FORCE
       $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
       $(build)=$(build-dir)
.....

Solution: here we have an implicit rule and an explicit rule in the same line, so we are going to split that rules.

# Modules #/ %/: prepare scripts FORCE # $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ # $(build)=$(build-dir) /: prepare scripts FORCE $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(build)=$(build-dir) %/: prepare scripts FORCE $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(build)=$(build-dir)

Wednesday, December 21, 2011

HowTo Clean and Re-build Squid cache

First, check your squid.conf file and locate the location of your cache directory, you should have a line starting with "cache_dir"

  1. Shutdown your squid server: squid -k shutdown
  2. Remove the cache directory: rm -r /squid/cache/*
  3. Re-Create the squid cache directory: squid -z
  4. Start the squid cache server
Thanks for reading.

Monday, December 12, 2011

IcePHP-3.2.1 Gentoo ebuild

The Internet Communications Engine, or Ice, is an object-oriented middleware that provides object-oriented Remote Procedure Call, grid computing and Publish/subscribe functionality developed by ZeroC and dual-licensed under the GNU GPL and a proprietary license. It supports C++, Java, . NET languages (such as C# or Visual Basic), Objective-C, Python, PHP, and Ruby on most major operating systems such as Linux, Solaris, Windows, and Mac OS X. A light variant of ICE runtime, called Ice-e, may run inside mobile phones. As its name indicates, the middleware may be used for internet applications without the need to use the HTTP protocol and is capable of traversing firewalls, unlike most other middleware.

Official Site: ICE
Wikipedia info: Wikipedia ICE info.


DEPRECATED HOW TO, CLICK HERE FOR THE CURRENT INFO.

Preparing the portage tree, more info HERE:

evo ~ # mkdir -p /usr/local/portage/profiles/ evo ~ # echo "Headup Overlay" > /usr/local/portage/profiles/repo_name evo ~ # mkdir -p /usr/local/portage/dev-php5/IcePHP/ evo ~ # echo "PORTDIR_OVERLAY=/usr/local/portage" >> /etc/make.conf evo ~ # cd /usr/local/portage/dev-php5/IcePHP/ evo IcePHP # wget http://headup.sytes.net/zbox/HeadupOverlay/dev-php5/IcePHP/IcePHP-3.2.1.ebuild evo IcePHP # ebuild IcePHP-3.2.1 manifest >>> Downloading 'http://www.zeroc.com/download/Ice/3.2/IcePHP-3.2.1.tar.gz' --2011-12-12 12:26:21-- http://www.zeroc.com/download/Ice/3.2/IcePHP-3.2.1.tar.gz Resolving www.zeroc.com (www.zeroc.com)... 184.73.227.248 Connecting to www.zeroc.com (www.zeroc.com)|184.73.227.248|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://download.zeroc.com/Ice/3.2/IcePHP-3.2.1.tar.gz [following] --2011-12-12 12:26:21-- http://download.zeroc.com/Ice/3.2/IcePHP-3.2.1.tar.gz Resolving download.zeroc.com (download.zeroc.com)... 216.137.43.110, 216.137.43.163, 216.137.43.119, ... Connecting to download.zeroc.com (download.zeroc.com)|216.137.43.110|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 78072 (76K) [application/x-tar] Saving to: `/usr/portage/distfiles/IcePHP-3.2.1.tar.gz' 100%[=================================================================>] 78,072 103K/s in 0.7s 2011-12-12 12:26:23 (103 KB/s) - `/usr/portage/distfiles/IcePHP-3.2.1.tar.gz' saved [78072/78072] >>> Creating Manifest for /usr/local/portage/dev-php5/IcePHP

Check the files

evo IcePHP # ll total 8 -rw-r--r-- 1 root root 994 Dec 2 15:04 IcePHP-3.2.1.ebuild -rw-r--r-- 1 root root 394 Dec 12 12:26 Manifest

 

Searching in our portage tree and portdir overlay:


evo IcePHP # emerge IcePHP -s Searching... [ Results for search key : IcePHP ] [ Applications found : 1 ] * dev-php5/IcePHP [ Masked ] Latest version available: 3.2.1 Latest version installed: [ Not Installed ] Size of files: 76 kB Homepage: http://www.zeroc.com Description: PHP bindings for the ICE middleware License: GPL-2

Preparing and making our system consistent (good practice):

evo IcePHP # echo dev-php5/IcePHP ~x86 >> /etc/portage/package.keywords evo IcePHP # emerge IcePHP -pv Calculating dependencies... done! >>> Verifying ebuild manifests >>> Emerging (1 of 1) dev-php5/IcePHP-3.2.1 from Headup-Overlay >>> Installing (1 of 1) dev-php5/IcePHP-3.2.1 >>> Jobs: 1 of 1 complete Load avg: 0.82, 1.89, 2.63 * Messages for package dev-php5/IcePHP-3.2.1: * Package: dev-php5/IcePHP-3.2.1 * Repository: Headup-Overlay * USE: elibc_glibc kernel_linux userland_GNU x86 * FEATURES: preserve-libs sandbox userpriv usersandbox * Package: dev-php5/IcePHP-3.2.1 * Repository: Headup-Overlay * USE: elibc_glibc kernel_linux userland_GNU x86 * FEATURES: preserve-libs sandbox userpriv usersandbox * * You must check the extensions configuration under the php.ini * file, and don't forget to restart your apache web server!! * * Removing /usr/share/info >>> Auto-cleaning packages... >>> No outdated packages were found on your system. * IMPORTANT: config file '/etc/dispatch-conf.conf' needs updating. * See the CONFIGURATION FILES section of the emerge * man page to learn how to update config files. * IMPORTANT: 6 news items need reading for repository 'gentoo'. * Use eselect news to read news items.

Configure the ICE extension in the PHP extension language.

evo IcePHP # cat /etc/php/apache2-php5/php.ini ... extension_dir = /etc/php/apache2-php5/ext extension = IcePHP.so ice.profiles = /etc/php/apache2-php5/profiles.ini ...

Configure the project profile.

evo IcePHP # cat /etc/php/apache2-php5/profiles.ini [IceProject] ice.config=/home/to/project/configure/client.configure ice.slice=-I/usr/share/Ice/slice /usr/share/Ice/slice/Glacier2/Router.ice /home/to/project/Slice/project.ice

And restart the apache web server

evo IcePHP # /etc/init.d/apache2 restart * Stopping apache2 ... [ ok ] * Starting apache2 ... [ ok ]