概要
H2 Databaseをインストールすることがメインなので、今回はパーミッション、アクセス権限は考えない
メモ
Javaをインストール
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# ダウンロードURL | |
DownloadURL="http://download.oracle.com/otn-pub/java/jdk/7u65-b17/jdk-7u65-linux-x64.tar.gz" | |
# インストール先 | |
InstallDirectory="/usr/local/java" | |
# シンボリック・リンク | |
JavaSymbolicLink=$InstallDirectory"/latest" | |
# ダウンロードファイル名 | |
DownloadFileName=${DownloadURL##*/} | |
LogFileName="$DownloadFileName""_install_""`date +%Y%m%d%H%M`.log" | |
### ダウンロード処理 | |
# | |
DownLoadFilePath="$InstallDirectory"/"$DownloadFileName" | |
LogFilePath="$InstallDirectory"/"$LogFileName" | |
echo "========== $DownloadFileName install start ==========" >> $LogFilePath | |
# ディレクトリチェック | |
if [ ! -e $InstallDirectory ]; then | |
mkdir -p $InstallDirectory | |
if [ $? -gt 0 ]; then | |
echo "Cannot create $InstallDirectory" | |
break; | |
fi | |
fi | |
# ファイルダウンロード | |
echo "========== ファイルダウンロード ==========" >> $LogFilePath | |
if [ ! -e $DownLoadFilePath ]; then | |
wget --no-cookies --no-check-certificate \ | |
--header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com; oraclelicense=accept-securebackup-cookie" $DownloadURL \ | |
-O $DownLoadFilePath \ | |
-a $LogFilePath | |
if [ $? -gt 0 ]; then | |
echo "Cannot download $DownloadURL" | |
rm -rf $DownLoadFilePath | |
break; | |
fi | |
else | |
echo "Already download $DownloadURL" | |
fi | |
### 解凍処理 | |
# | |
echo "========== 解凍処理 ==========" >> $LogFilePath | |
# 解凍したフォルダ名 | |
UnzippedDirectoryName=$(tar tfz $DownLoadFilePath | head -1) | |
UnzippedDirectoryPath=$InstallDirectory"/"$UnzippedDirectoryName | |
if [ ! -e $UnzippedDirectoryPath ]; then | |
tar zxvfC $DownLoadFilePath $InstallDirectory >> $LogFilePath | |
else | |
echo "Already install $UnzippedDirectoryPath" | |
fi | |
### シンボリックリンク作成 | |
# | |
ln -snf $UnzippedDirectoryPath $JavaSymbolicLink | |
echo "========== $DownloadFileName install end ==========" >> $LogFilePath |
H2 DataBaseをインストール
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# ダウンロードURL | |
DownloadURL="http://www.h2database.com/h2-2014-08-06.zip" | |
# インストール先 | |
InstallDirectory="/opt/database" | |
# | |
# ダウンロードファイル名 | |
DownloadFileName=${DownloadURL##*/} | |
LogFileName="$DownloadFileName""_install_""`date +%Y%m%d%H%M`.log" | |
### ダウンロード処理 | |
# | |
DownLoadFilePath="$InstallDirectory"/"$DownloadFileName" | |
LogFilePath="$InstallDirectory"/"$LogFileName" | |
echo "========== $DownloadFileName install start ==========" >> $LogFilePath | |
# ディレクトリチェック | |
if [ ! -e $InstallDirectory ]; then | |
mkdir -p $InstallDirectory | |
if [ $? -gt 0 ]; then | |
echo "Cannot create $InstallDirectory" | |
break; | |
fi | |
fi | |
echo "========== ファイルダウンロード ==========" >> $LogFilePath | |
if [ ! -e $DownLoadFilePath ]; then | |
wget $DownloadURL \ | |
-O $DownLoadFilePath \ | |
-a $LogFilePath | |
if [ $? -gt 0 ]; then | |
echo "Cannot download $DownloadURL" | |
rm -rf $DownLoadFilePath | |
break; | |
fi | |
else | |
echo "Already download $DownloadURL" | |
fi | |
### 解凍処理 | |
# | |
echo "========== 解凍処理 ==========" >> $LogFilePath | |
# 解凍したフォルダ名 | |
UnzippedDirectoryPath=$InstallDirectory"/h2" | |
if [ ! -e $UnzippedDirectoryPath ]; then | |
unzip -n $DownLoadFilePath -d $InstallDirectory >> $LogFilePath | |
else | |
echo "Already install $UnzippedDirectoryPath" | |
fi | |
echo "========== $DownloadFileName install end ==========" >> $LogFilePath | |
H2 DataBaseに接続
# H2 DataBaseに起動 /usr/local/java/latest/bin/java -cp /opt/database/h2/bin/*.jar org.h2.tools.Server Welcome to H2 Shell 1.3.173 (2013-07-28) Exit with Ctrl+C [Enter] jdbc:h2:~/test URL [Enter] org.h2.Driver Driver [Enter] sa User [Enter] Hide Password Password Connected Commands are case insensitive; SQL statements end with ';' help or ? Display this help list Toggle result list / stack trace mode maxwidth Set maximum column width (default is 100) autocommit Enable or disable autocommit history Show the last 20 statements quit or exit Close the connection and exit sql> SELECT * FROM INFORMATION_SCHEMA.CATALOGS ; CATALOG_NAME TEST (1 row, 7 ms) sql> exit; Connection closed