Skip to content

Instantly share code, notes, and snippets.

@oh-sky
Last active December 11, 2015 22:49
Show Gist options
  • Save oh-sky/4672302 to your computer and use it in GitHub Desktop.
Save oh-sky/4672302 to your computer and use it in GitHub Desktop.
http.conf を、同階層の{domain.example.com}.conf へのソフトリンクにするスクリプト
$ ls -l /opt/local/apache2/conf
bar.example.com.conf
foo.example.com.conf 
httpd.conf@ -> bar.example.com.conf

$ sudo a2ensite foo.example.com
$ls -l /opt/local/apache2/conf
bar.example.com.conf
foo.example.com.conf 
httpd.conf@ -> foo.example.com.conf
#!/bin/bash
CONFIG_DIR=/opt/local/apache2/conf/
CONFIG_FILE=httpd.conf
SLINK_NAME="${CONFIG_DIR}${CONFIG_FILE}"
TARGET_NAME="${CONFIG_DIR}${1}.conf"
if [ -f $TARGET_NAME ]
then
echo $TARGET_NAME
if [ -f $SLINK_NAME ]
then
echo "removing ${SLINK_NAME} ..."
rm -f $SLINK_NAME
echo "ln -s ${TARGET_NAME} ${SLINK_NAME}"
ln -s $TARGET_NAME $SLINK_NAME
if [ $? -eq 0 ] ; then
echo "ok"
fi
fi
else
echo "err : ${TARGET_NAME} doesn't exist."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment