创建应用文件:createCIApp.sh
#!/bin/bash #@author Zjmainstay #@website http://zjmainstay.cn #@copyright GPL # @version 1.0 # @year 2014 #Get file path FILE_PATH=$0 FILE_PATH_BAK="$FILE_PATH.bak" FILE_PATH_INSTALLED="$FILE_PATH.installed" pwd FILE_DIR=`dirname $0` FILE_NAME=${FILE_PATH##*/} #App name read -p "Please input your app name: " app if [ -z $app ] then echo "Please input your app name." exit fi function getpasswordsum() { local password=$1 #Save password in tmp file local PASSWORD_FILE="/tmp/passwd" echo $password > $PASSWORD_FILE #md5sum password file local md5sumfile=`md5sum $PASSWORD_FILE` #remove it rm $PASSWORD_FILE #get md5sum part passwordsum=${md5sumfile%% *} echo $passwordsum } #install password INSTALL_PASSWORD="install_password" #realpassword set before for match realpasswordsum="$INSTALL_PASSWORD" if [ $realpasswordsum == $INSTALL_PASSWORD ] then read -p "Please set your install password: " initpassword read -p "Please confirm your install password: " confirmpassword if [ $initpassword != $confirmpassword ] then echo "Password is not match." exit else #install password initpasswordsum=`getpasswordsum $initpassword` CMD_REPLACE_PASSWORD="cat $FILE_NAME | sed 's/realpasswordsum=\"\$INSTALL_PASSWORD\"/realpasswordsum=\"$initpasswordsum\"/g' > $FILE_PATH_INSTALLED" echo $CMD_REPLACE_PASSWORD | sh fi else # Password check read -p "Please input your password: " password if [ -z $password ] then echo "Please input your password." exit else inputpasswordsum=`getpasswordsum $password` if [ "$inputpasswordsum" != "$realpasswordsum" ] then echo "Password Error." exit fi fi fi #######============================= #path HOME_PATH=~ FRAMEWORK_PATH="$HOME_PATH/Framework" CI_FRAMEWORK_PATH="$FRAMEWORK_PATH/CodeIgniter" WEB_PATH="$HOME_PATH/Web" APP_PATH="$HOME_PATH/Applications/$app" APP_PUBLIC_PATH="$APP_PATH/www" #create framework dir if [ ! -d $FRAMEWORK_PATH ] then mkdir $FRAMEWORK_PATH fi #download CodeIgniter Framework if [ ! -d $CI_FRAMEWORK_PATH ] then cd $FRAMEWORK_PATH git clone https://github.com/EllisLab/CodeIgniter fi #check if app exists if [ -d $APP_PATH ] then echo "App is exists, Please change your app name" exit fi #do create app #create app dir mkdir $APP_PATH #copy CodeIgniter framework to app dir cp -R $CI_FRAMEWORK_PATH/* $APP_PATH #delete system dir, use symbol link instead rm -rf $APP_PATH/system ln -s $CI_FRAMEWORK_PATH/system $APP_PATH/system #rm user guide src dir rm -rf $APP_PATH/user_guide_src #create web visit dir, use symbol link from application path mkdir $APP_PUBLIC_PATH #replace app visit file to relative path CMD_REPLACE="cat $APP_PATH/index.php | sed \"s/'system'/'..\/system'/g\" | sed \"s/'application'/'..\/application'/g\" > $APP_PUBLIC_PATH/index.php" echo $CMD_REPLACE | sh #link app public dir to web ln -s $APP_PUBLIC_PATH $WEB_PATH/$app #if first install if [ -f $FILE_PATH_INSTALLED ] then #bak install sh, and replace into installed mv $FILE_PATH $FILE_PATH_BAK mv $FILE_PATH_INSTALLED $FILE_PATH chmod 744 $FILE_PATH fi echo "App $app created."
删除应用文件:deleteCIApp.sh
#!/bin/bash #@author Zjmainstay #@website http://zjmainstay.cn #@copyright GPL # @version 1.0 # @year 2014 #Get file path FILE_PATH=$0 FILE_PATH_BAK="$FILE_PATH.bak" FILE_PATH_INSTALLED="$FILE_PATH.installed" pwd FILE_DIR=`dirname $0` FILE_NAME=${FILE_PATH##*/} #App name read -p "Please input your app name: " app if [ -z $app ] then echo "Please input your app name." exit fi function getpasswordsum() { local password=$1 #Save password in tmp file local PASSWORD_FILE="/tmp/passwd" echo $password > $PASSWORD_FILE #md5sum password file local md5sumfile=`md5sum $PASSWORD_FILE` #remove it rm $PASSWORD_FILE #get md5sum part passwordsum=${md5sumfile%% *} echo $passwordsum } #install password INSTALL_PASSWORD="install_password" #realpassword set before for match realpasswordsum="$INSTALL_PASSWORD" if [ $realpasswordsum == $INSTALL_PASSWORD ] then read -p "Please set your install password: " initpassword read -p "Please confirm your install password: " confirmpassword if [ $initpassword != $confirmpassword ] then echo "Password is not match." exit else #install password initpasswordsum=`getpasswordsum $initpassword` CMD_REPLACE_PASSWORD="cat $FILE_NAME | sed 's/realpasswordsum=\"\$INSTALL_PASSWORD\"/realpasswordsum=\"$initpasswordsum\"/g' > $FILE_PATH_INSTALLED" echo $CMD_REPLACE_PASSWORD | sh fi else # Password check read -p "Please input your password: " password if [ -z $password ] then echo "Please input your password." exit else inputpasswordsum=`getpasswordsum $password` if [ "$inputpasswordsum" != "$realpasswordsum" ] then echo "Password Error." exit fi fi fi #######============================= #Do remove app HOME_PATH=~ APP_PATH="$HOME_PATH/Applications/$app" WEB_PATH="$HOME_PATH/Web" #check app exists if [ ! -d $APP_PATH ] then echo "App $app is not exists, please check it." if [ -f $FILE_PATH_INSTALLED ] then rm $FILE_PATH_INSTALLED fi exit fi #remove app dir rm -rf $APP_PATH #remove web symbol link rm $WEB_PATH/$app #if first install if [ -f $FILE_PATH_INSTALLED ] then #bak install sh, and replace into installed mv $FILE_PATH $FILE_PATH_BAK mv $FILE_PATH_INSTALLED $FILE_PATH chmod 744 $FILE_PATH fi echo "App $app removed."Friendly Link: Koding.com - 免费Linux开发平台
未经同意禁止转载!
转载请附带本文原文地址:Shell for quick start with CodeIgniter in koding,首发自 Zjmainstay学习笔记