2011年9月16日 星期五

gitosis

Install gitosis (server side)
>git clone git://eagain.net/gitosis.git
>cd gitosis >sudo python setup.py install

add user 'git' (server side)
>sudo adduser git
>sudo passwd git

generate a admin public key (from client side) and put on server side
the key is put on /home/git/id_rsa.pub

Initialize gitosis (server side)
>su git
>cd /home/git
>gitosis-init < id_rsa.pub
>rm id_rsa.pub


Now we must set some directory and file permissions to let sshd see the new authorized_keys file.

>chmod 755 /home/git
>chmod 700 /home/git/.ssh
>chmod 644 /home/git/.ssh/authorized_keys


Make sure post-update is executeable
Cole on November 19, 2009 03:53 PM
I was still getting the ERROR:gitosis.serve.main:Repository read access denied problem after rechecking everything that was said here. I finally found the answer on stackoverflow. Make sure your repositories/gitosis-admin.git/hooks/post-update is executable. Enjoy

prevent "ERROR:gitosis.serve.main:Repository read access denied"

clone gitosis from server (client side)
>git clone git@server.com:gitosis-admin.git

edit gitosis.conf
>cd gitosis-admin
>vim gitosis.conf
(refer following link to modify conf file)

http://nfocipher.com/index.php?op=ViewArticle&articleId=12&blogId=1
http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
http://theswarmintelligence.blogspot.com/2009/11/creating-gitosis-repository-and-adding.html

Ready to git hosting on remote!

2011年8月17日 星期三

install mysql and phpmyadmin via yum

1. install mysql and mysql-server
# yum install mysql mysql-server

2. start mysql server
# service mysqld start

3. change mysql root password
# mysqladmin ping -u root -p'' password 'newpassword'
Enter password: your-root-mysql-adminpasswd-here
mysqld is alive

4. install rpmforge
refer to: http://wiki.centos.org/AdditionalResources/Repositories/RPMForge

5.  yum install phpmyadmin

6. modify config.inc.php
# vim /usr/share/phpmyadmin/config.inc.php
$cfg['blowfish_secret'] = 'any-string-you wants for encryption';

7. modify phpmyadmin.conf
# vim /etc/httpd/conf.d/phpmyadmin.conf
replace "Allow from 127.0.0.1" to "Allow from all"
(Note: It allow any client login to your phpmyadmin)

8. restart Apache
# service httpd restart

9. open browser "http://server/phpmyadmin
login with root/your-root-mysql-adminpasswd-here

reference:
http://www.linuxforums.org/forum/red-hat-fedora-linux/57941-how-install-phpmyadmin-via-yum.html
http://www.shocr.com/yum-install-phpmyadmin/
http://www.cyberciti.biz/faq/mysql-change-root-password/

2011年8月10日 星期三

install lxml

1. yum install libxml2-devel libxslt-devel python-devel

2. easy_install --allow-host=lxml.de,*python.org lxml

reference:
http://lxml.de/installation.html

2011年8月6日 星期六

install webmin on Amazon linux

1. wget http://www.webmin.com/download/rpm/webmin-current.rpm

2. sudo rpm -ivh webmin-xxxx

3. sudo vim /etc/webmin/miniserv.users
>refer the first line, add line:
ec2-user:x:0
4. sudo vim /etc/webmin/webmin.acl
>refer the first line, add line:
ec2-user: xxxxxxxxxxxxxxxxxxxx

5. sudo /usr/libexec/webmin/changepass.pl /etc/webmin ec2-user password
("password" is YOUR password)

6. service webmin start

7. open port 10000 on AWS Security Group

8. try to login with ec2-user/password on http://your_server:10000/

reference:
http://www.pc-freak.net/blog/how-to-add-a-new-user-to-webmin-from-shell-via-bashsh/

2011年8月4日 星期四

subversion

1. # yum install mod_dav_svn subversion

2. # cd /etc/httpd/conf.d/
# vim subversion.conf

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
<Location /repos>
DAV svn
SVNPath /var/www/svn/repos
AuthType Basic
AuthName "Subversion repos"
AuthUserFile /etc/svn-auth-conf
Require valid-user
</Location>

3. htpasswd -cm /etc/svn-auth-conf yourusername
New password:
Re-type new password:
Adding password for user yourusername

reference:
http://wiki.centos.org/HowTos/Subversion

2011年7月26日 星期二

python getopt



import getopt, sys

def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="])
except getopt.GetoptError, err:
# print help information and exit:
print str(err) # will print something like "option -a not recognized"
usage()
sys.exit(2)
output = None
verbose = False
for o, a in opts:
if o == "-v":
verbose = True
elif o in ("-h", "--help"):
usage()
sys.exit()
elif o in ("-o", "--output"):
output = a
else:
assert False, "unhandled option"
# ...

if __name__ == "__main__":
main()


"ho:v" 允許-h -o -v, 其中-o需要參數(後面多:)
["help", "output="] 允許--help --output, 其中--output需要參數(後面多=)

http://docs.python.org/library/getopt.html

python subprocess


#!/usr/bin/python
from subprocess import *
from shlex import *

command = "ls -l"
print command
output = Popen(split(command), stdout=PIPE, stderr=PIPE)
outputData = output.communicate()[0]
returncode = output.returncode





http://docs.python.org/library/subprocess.html