class SimpleTool
Public Class Methods
source_root()
click to toggle source
# File lib/simpletool.rb, line 7 def self.source_root File.dirname(__FILE__) end
Public Instance Methods
cp_file(src, dest, sudo=false)
click to toggle source
# File lib/simpletool.rb, line 12 def cp_file(src, dest, sudo=false) command = 'cp -r ' + SimpleTool.source_root + '/' + src + ' ' + dest command = 'sudo ' + command if sudo ap command `#{command}` end
install_ftp(username, passwd)
click to toggle source
# File lib/simpletool.rb, line 52 def install_ftp(username, passwd) `sudo apt-get --yes install wget vsftpd` `sudo useradd #{username}` `sudo mkdir /home/#{username}` `sudo chown "#{username}:#{username}" "/home/$1"` `sudo bash -c "echo '#{username}:#{passwd}' | /usr/sbin/chpasswd"` `sudo rm /etc/pam.d/vsftpd` cp_file('support/ftp/vsftpd.conf', '/etc/vsftpd.conf', true) `sudo service vsftpd restart` end
install_phpmyadmin()
click to toggle source
# File lib/simpletool.rb, line 37 def install_phpmyadmin `sudo apt-get -y install nginx php5-cli php5-cgi php5-fpm php5-mcrypt php5-mysql php5-gd php-apc php5-common` #modify mysql.ini `sudo sed -i'' -e '/bind-address/d' /etc/mysql/my.cnf` `wget https://files.phpmyadmin.net/phpMyAdmin/4.4.15.8/phpMyAdmin-4.4.15.8-english.tar.gz -O phpmyadmin.tar.gz` `tar -xvzf phpmyadmin.tar.gz` `sudo mv phpMyAdmin-4.4.15.8-english /usr/share/nginx/html/phpmyadmin` cp_file('support/phpmyadmin/nginx.phpmyadmin.default', '/etc/nginx/sites-enabled/nginx.phpmyadmin.default', true) `sudo service nginx reload` `sudo service php5-fpm restart` end
install_pptp_vpn(user, pwd)
click to toggle source
# File lib/simpletool.rb, line 23 def install_pptp_vpn(user, pwd) ap "hello" `sudo apt-get install --yes pptpd pptp-linux` cp_file('support/pptp_vpn/ubuntu/pptpd.conf', '/etc/pptpd.conf', true) cp_file('support/pptp_vpn/ubuntu/pptpd-options', '/etc/ppp/pptpd-options', true) `sudo bash -c "echo '#{user} * #{pwd} *' >> /etc/ppp/chap-secrets"` cp_file('support/pptp_vpn/ubuntu/sysctl.conf', '/etc/sysctl.conf', true) cp_file('support/pptp_vpn/ubuntu/rc.local', '/etc/rc.local', true) `sudo modprobe nf_conntrack_proto_gre nf_conntrack_pptp` `sudo /etc/init.d/pptpd restart` `echo 'pleaese reboot to make it works'` end
install_zsh()
click to toggle source
# File lib/simpletool.rb, line 64 def install_zsh `sudo apt-get --yes install git zsh autojump` `mkdir ~/opensource` `git clone https://github.com/robbyrussell/oh-my-zsh ~/.oh-my-zsh` `git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/opensource/zsh-syntax-highlighting` `git clone https://github.com/zsh-users/zsh-history-substring-search.git ~/opensource/zsh-history-substring-search` `git clone https://github.com/olivierverdier/zsh-git-prompt.git ~/opensource/zsh-git-prompt` cp_file('support/zsh/.zshrc', '~/.zshrc') `sudo chsh -s $(which zsh)` `zsh` end