Pesquisar neste blog

quarta-feira, 22 de abril de 2015

Mounting ext4 partitions in Debian

As of Debian 5.04 (Lenny), Debian doesn’t support mounting ext4 partitions out of the box, or rather, we should say, using conventional methods.
Trying to mount an ext4 partition using the mount directive yields the error :
?
1
mount: unknown filesystem type 'ext4'
The roundabout way of doing it is setting a test_fs flag on the partition using the tune2fs utility.
?
1
2
3
su -
tune2fs -E test_fs /dev/hda1
mount -t ext4dev /dev/hda1 /place/to/mount/
Replace hda1 with the name of the ext4 partition you want to mount.

quinta-feira, 9 de abril de 2015

Serial Console customization of debian-installer CD or DVD

This should work on the CD or DVD image.  Illustrated below is the steps for the CD image.

First, if you do not have an ISO image already, download CD1 via jigdo or bittorrent. If I had more time, I'd probably screencast how to do all that, but if you fetch the .jigdo and have jigdo installed, it's downhill from there.

mkdir /mnt/debian-7.8.0-i386-CD1-ttyS0

sudo mount -o loop,ro debian-7.2.0-amd64-CD-1.iso /media/cdrom

rsync -av /media/cdrom/ /mnt/debian-7.8.0-i386-CD1-ttyS0/

Open the file below:
isolinux/isolinux.cfg:

serial 0 115200 prompt 0 timeout 0 default install label install menu label ^Install menu default kernel /install.amd/vmlinuz append term=linux priority=low console=ttyS0,115200 text initrd=/install.amd/initrd.gz --

save and quit

Run the command below:

sudo genisoimage -r -J -b /mnt/debian-7.8.0-i386-CD1-ttyS0/isolinux/isolinux.bin -c /mnt/debian-7.8.0-i386-CD1-ttyS0/isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /tmp/debian-7.2.0-amd64-CD-1-ttyS0.iso /mnt/debian-7.8.0-i386-CD1-ttyS0

Burn your CD with new ISO.
Finish

quinta-feira, 15 de janeiro de 2015

The Perfect APC Configuration

Here was my setup on an Amazon Medium Instance using APC:
php.ini configuration
[APC]
extension=apc.so
apc.enabled=1
apc.shm_segments=1

;32M per WordPress install
apc.shm_size=128M

;Relative to the number of cached files (you may need to watch your stats for a day or two to find out a good number)
apc.num_files_hint=7000

;Relative to the size of WordPress
apc.user_entries_hint=4096

;The number of seconds a cache entry is allowed to idle in a slot before APC dumps the cache
apc.ttl=7200
apc.user_ttl=7200
apc.gc_ttl=3600

;Setting this to 0 will give you the best performance, as APC will
;not have to check the IO for changes. However, you must clear 
;the APC cache to recompile already cached files. If you are still
;developing, updating your site daily in WP-ADMIN, and running W3TC
;set this to 1
apc.stat=1

;This MUST be 0, WP can have errors otherwise!
apc.include_once_override=0

;Only set to 1 while debugging
apc.enable_cli=0

;Allow 2 seconds after a file is created before it is cached to prevent users from seeing half-written/weird pages
apc.file_update_protection=2

;Leave at 2M or lower. WordPress does't have any file sizes close to 2M
apc.max_file_size=2M

;Ignore files
apc.filters = "/var/www/apc.php"

apc.cache_by_default=1
apc.use_request_time=1
apc.slam_defense=0
apc.mmap_file_mask=/var/www/temp/apc.XXXXXX
apc.stat_ctime=0
apc.canonicalize=1
apc.write_lock=1
apc.report_autofilter=0
apc.rfc1867=0
apc.rfc1867_prefix =upload_
apc.rfc1867_name=APC_UPLOAD_PROGRESS
apc.rfc1867_freq=0
apc.rfc1867_ttl=3600
apc.lazy_classes=0
apc.lazy_functions=0
While this configuration works great for me, it may not for you. Finding “The Perfect APC Configuration” is like asking how many stars are in the sky. The are endless variables, like, “How much RAM, how many websites, do your websites support lazy classes, etc…” The best way to create your config is to do a little research. This post was meant to give you a push in the right direction.
P.S. There seems to be a lot of debate about apc.stat = 0. The general thought is, set apc.stat=0 on production servers and it will prevent APC from actually going to the IO to check if the file has been changed. However, the WordPress dashboard and W3TC get kinda bitchy with this setting!
My advice: Are working in the WordPress dashboard daily, and running W3TC? Then set: apc.stat = 1. Your fragmentation will be higher. Your sites will loadslightly slower, but when you click Update Post, APC will flush that piece of cache.

Source:  Greg Rickaby

sexta-feira, 19 de dezembro de 2014

Desvio Condicional em Shell Script




Para efetuar teste condicionais, o shell script possui operadores de verificação como (maior/menor/menor que/igual/ etc …) veja abaixo os exemplos :

if [ condição ]; then
    comando...1
    comando...2
    comando...N
fi

-eq igual
-ne diferente
-gt maior
-ge maior ou igual
-lt menor
-le menor ou igual
-d se é um diretório
-e se existe
-z se é vazio
-f se contem texto.
-r se o arquivo possui permissão de leitura
-w se o arquivo possui permissão de escrita.
-x se o arquivo é executável.



quinta-feira, 18 de dezembro de 2014

Unix - Special Variables

Previous tutorial warned about using certain nonalphanumeric characters in your variable names. This is because those characters are used in the names of special Unix variables. These variables are reserved for specific functions.
For example, the $ character represents the process ID number, or PID, of the current shell:
$echo $$
Above command would write PID of the current shell:
29949
The following table shows a number of special variables that you can use in your shell scripts:
VariableDescription
$0The filename of the current script.
$nThese variables correspond to the arguments with which a script was invoked. Here n is a positive decimal number corresponding to the position of an argument (the first argument is $1, the second argument is $2, and so on).
$#The number of arguments supplied to a script.
$*All the arguments are double quoted. If a script receives two arguments, $* is equivalent to $1 $2.
$@All the arguments are individually double quoted. If a script receives two arguments, $@ is equivalent to $1 $2.
$?The exit status of the last command executed.
$$The process number of the current shell. For shell scripts, this is the process ID under which they are executing.
$!The process number of the last background command.

Command-Line Arguments:

The command-line arguments $1, $2, $3,...$9 are positional parameters, with $0 pointing to the actual command, program, shell script, or function and $1, $2, $3, ...$9 as the arguments to the command.
Following script uses various special variables related to command line:
#!/bin/sh

echo "File Name: $0"
echo "First Parameter : $1"
echo "First Parameter : $2"
echo "Quoted Values: $@"
echo "Quoted Values: $*"
echo "Total Number of Parameters : $#"
Here is a sample run for the above script:
$./test.sh Zara Ali
File Name : ./test.sh
First Parameter : Zara
Second Parameter : Ali
Quoted Values: Zara Ali
Quoted Values: Zara Ali
Total Number of Parameters : 2

Special Parameters $* and $@:

There are special parameters that allow accessing all of the command-line arguments at once. $* and $@ both will act the same unless they are enclosed in double quotes, "".
Both the parameter specifies all command-line arguments but the "$*" special parameter takes the entire list as one argument with spaces between and the "$@" special parameter takes the entire list and separates it into separate arguments.
We can write the shell script shown below to process an unknown number of command-line arguments with either the $* or $@ special parameters:
#!/bin/sh

for TOKEN in $*
do
   echo $TOKEN
done
There is one sample run for the above script:
$./test.sh Zara Ali 10 Years Old
Zara
Ali
10
Years
Old
Note: Here do...done is a kind of loop which we would cover in subsequent tutorial.

Exit Status:

The $? variable represents the exit status of the previous command.
Exit status is a numerical value returned by every command upon its completion. As a rule, most commands return an exit status of 0 if they were successful, and 1 if they were unsuccessful.
Some commands return additional exit statuses for particular reasons. For example, some commands differentiate between kinds of errors and will return various exit values depending on the specific type of failure.
Following is the example of successful command:
$./test.sh Zara Ali
File Name : ./test.sh
First Parameter : Zara
Second Parameter : Ali
Quoted Values: Zara Ali
Quoted Values: Zara Ali
Total Number of Parameters : 2
$echo $?
0
$
Fonte: tutorialspoint