Skip to content

Instantly share code, notes, and snippets.

@kashiwasan
Created March 12, 2016 16:10
Show Gist options
  • Save kashiwasan/8be2cde4e335c45d32d8 to your computer and use it in GitHub Desktop.
Save kashiwasan/8be2cde4e335c45d32d8 to your computer and use it in GitHub Desktop.
サーバ管理用(ユーザ追加・管理)
#!/bin/bash
# 使い方: ./useradd_scirpt.sh username password
# 注意: XXXXXX の部分を mysql のrootパスワードに置き換えてください。
useradd -G wheel $1
echo $2 | passwd --stdin $1
su $1 -c "ssh-keygen"
su $1 -c "touch ~/.ssh/authorized_keys"
su $1 -c "mkdir ~/public_html/"
su $1 -c "chmod 0777 ~/public_html/"
ln -s /home/$1/public_html /var/www/html/$1
chmod 0707 /home/$1
echo "create database $1" | mysql -u root -pXXXXXX
echo "grant all on \`$1%\`.* to $1@localhost identified by '$2'" | mysql -u root -pXXXXXX
# cp /etc/httpd/conf.d/kashiwagi-vhosts.conf /etc/httpd/conf.d/$1-vhosts.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment