;---------------------------
;sgt.AI Server Setup Macro
;'login.txt' include
;---------------------------

;■ファイル存在チェック
errcode = 0
filesearch 'login.txt'
if result = 0 then
  messagebox "テキストファイル login.txt が存在しません！" "login.txt エラー"
  messagebox "同じフォルダ内に login.txt を入れてください" "login.txt エラー"
  errcode = 1
  exit
endif

;■ログイン情報テキストインクルード
include 'login.txt'

;■'login.txt'内 変数存在チェック
ifdefined username
if result = 0 then
  messagebox 'login.txt に username が記述されていません！' 'username エラー'
  errcode = 1
endif
ifdefined hostname
if result = 0 then
  messagebox 'login.txt に hostname が記述されていません！' 'hostname エラー'
  errcode = 1
endif
ifdefined ubuspswd
if result = 0 then
  messagebox 'login.txt に ubuspswd が記述されていません！' 'ubuspswd エラー'
  errcode = 1
endif
ifdefined psqlpswd
if result = 0 then
  messagebox 'login.txt に psqlpswd が記述されていません！' 'psqlpswd エラー'
  errcode = 1
endif
ifdefined sgtaipwd
if result = 0 then
  messagebox 'login.txt に sgtaipwd が記述されていません！' 'sgtaipwd エラー'
  errcode = 1
endif

;■'login.txt'内 パスワード文字数チェック（8文字未満は不可）
strlen ubuspswd
if result < 8 then
  messagebox 'ユーザーパスワードは8文字以上が必須です！' 'login.txt パスワードエラー'
  errcode = 1
  exit
endif
strlen psqlpswd
if result < 8 then
  messagebox 'PostgreSQLパスワードは8文字以上が必須です！' 'login.txt パスワードエラー'
  errcode = 1
  exit
endif
strlen sgtaipwd
if result < 8 then
  messagebox 'sgt.AIパスワードは8文字以上が必須です！' 'login.txt パスワードエラー'
  errcode = 1
  exit
endif

;■'login.txt'内 パスワード整合性チェック
strcompare ubuspswd "xxxxxxxx"
if result = 0 then
  messagebox 'ユーザーパスワードが設定されていません！' 'login.txt パスワードエラー'
  errcode = 1
  exit
endif
strcompare psqlpswd "xxxxxxxx"
if result = 0 then
  messagebox 'PostgreSQLパスワードが設定されていません！' 'login.txt パスワードエラー'
  errcode = 1
  exit
endif
strcompare sgtaipwd "xxxxxxxx"
if result = 0 then
  messagebox 'sgt.AIパスワードが設定されていません！' 'login.txt パスワードエラー'
  errcode = 1
  exit
endif
