Commit 5c4a6ff2 authored by platyhouse's avatar platyhouse

# 문서 및 설치 스크립트 개선, PHP 5.6 호환성 수정

## 문서 업데이트

### 프로젝트 이름 변경
- CLAUDE.md: 프로젝트명을 "pty_centos.git"에서 "ptyUtils"로 변경
- README.md: 프로젝트명을 "pty_centos"에서 "ptyUtils"로 변경

### 설치 문서 구조 개선
- CLAUDE.md: 설치 섹션을 사용자 설치(ptyInstall.sh)와 전역 설치(ptyInstallGlobal.sh)로 분리
- CLAUDE.md: ptySetBash의 --install-global 옵션 문서 추가
- CLAUDE.md: 설치 경로를 ~/ptyUtils.git과 /var/lib/ptyUtils.git으로 명확히 정리
- README.md: 설치 안내를 사용자 설치(권장)와 전역 설치로 분리하여 재구성
- README.md: 수동 설치 가이드에 사용자 설치와 전역 설치 예시 추가
- README.md: 유틸리티 스크립트 표에 ptyInstall.sh, ptyInstallGlobal.sh 추가

## PHP 5.6 호환성 수정

### null 병합 연산자(??) 제거
- ptyMysqlBackup: `??` 연산자를 `isset() ? :` 삼항 연산자로 변경
- ptyMysqlRestore: `??` 연산자를 `isset() ? :` 삼항 연산자로 변경
parent 8de5e743
......@@ -4,7 +4,7 @@
## 프로젝트 개요
pty_centos.git은 Elasticsearch, MySQL 등 다양한 서비스를 다루는 CLI 도구 모음입니다.
ptyUtils는 Elasticsearch, MySQL 등 다양한 서비스를 다루는 CLI 도구 모음입니다.
## 네임스페이스
......@@ -445,9 +445,9 @@ charset=utf8mb4
## 설치
### ptyInstall.sh - 원격 설치 스크립트
### ptyInstall.sh - 사용자 설치 스크립트
신규 서버에 pty_centos를 설치하는 스크립트입니다. curl 또는 wget으로 원격 실행할 수 있습니다.
사용자 홈 디렉토리에 ptyUtils를 설치하는 스크립트입니다.
```bash
# curl 사용
......@@ -457,30 +457,67 @@ curl -sSL https://gitlab.platyhouse.com/platyhouse/centos/-/raw/master/ptyInstal
wget -qO- https://gitlab.platyhouse.com/platyhouse/centos/-/raw/master/ptyInstall.sh | bash
```
**동작 순서:**
1. git 설치 확인 (없으면 자동 설치: yum/dnf/apt-get/brew 지원)
2. 기존 설치 확인
- 기존 설치 있음: `git pull`로 업데이트
- 신규 설치: `git clone`으로 설치
3. 실행 권한 부여 (`pty*` 스크립트들에 chmod +x)
4. `ptySetBash` 실행 (`~/.bashrc` 또는 `~/.zshrc`에 설정 추가)
**설치 경로:** `~/ptyUtils.git`
**설정 파일:** `~/.bashrc` (macOS: `~/.zshrc`)
**설치 후:**
```bash
source ~/.bashrc # 또는 새 터미널 열기
```
### ptyInstallGlobal.sh - 전역 설치 스크립트
시스템 전역에 ptyUtils를 설치하는 스크립트입니다. root 권한이 필요합니다.
```bash
# curl 사용
curl -sSL https://gitlab.platyhouse.com/platyhouse/centos/-/raw/master/ptyInstallGlobal.sh | bash
# wget 사용
wget -qO- https://gitlab.platyhouse.com/platyhouse/centos/-/raw/master/ptyInstallGlobal.sh | bash
```
**동작 순서:**
1. root 권한 확인 (필요 시 sudo로 재실행)
2. git 설치 확인 (없으면 자동 설치: yum/dnf/apt-get/brew 지원)
2. git 설치 확인 (없으면 자동 설치: yum/dnf/apt-get 지원)
3. 기존 설치 확인
- 기존 설치 있음: `git pull`로 업데이트
- 신규 설치: `git clone`으로 설치
4. 실행 권한 부여 (`pty*` 스크립트들에 chmod +x)
5. `ptySetBash` 실행 (bash 환경 설정)
5. `ptySetBash --install-global` 실행 (`/etc/bashrc`에 설정 추가)
**설치 경로:** `/var/lib/pty_centos.git`
**설치 경로:** `/var/lib/ptyUtils.git`
**설정 파일:** `/etc/bashrc` (모든 사용자에게 적용)
**설치 후:**
```bash
source ~/.bashrc # 또는 새 터미널 열기
source /etc/bashrc # 또는 새 터미널 열기
```
### ptySetBash - Bash 환경 설정
bash/zsh 환경을 설정하는 스크립트입니다. ptyInstall.sh에서 자동 호출됩니다.
bash/zsh 환경을 설정하는 스크립트입니다. 설치 스크립트에서 자동 호출됩니다.
```bash
./ptySetBash
./ptySetBash # ~/.bashrc 또는 ~/.zshrc에 설정
./ptySetBash --install-global # /etc/bashrc에 설정 (Linux, root 필요)
```
**옵션:**
| 옵션 | 설명 |
|------|------|
| (기본) | `~/.bashrc` (Linux) 또는 `~/.zshrc` (macOS)에 설정 |
| `--install-global` | `/etc/bashrc`에 설정 (Linux 전용, root 필요) |
**설정 내용:**
- 프롬프트 설정 (git branch 표시 포함)
- 히스토리 설정 (HISTSIZE, HISTTIMEFORMAT)
......@@ -488,10 +525,6 @@ bash/zsh 환경을 설정하는 스크립트입니다. ptyInstall.sh에서 자
- git 설정 (color, quotepath, precomposeunicode)
- PATH에 스크립트 경로 추가
**대상 파일:**
- macOS: `~/.zshrc`
- Linux: `~/.bashrc` (선택적으로 `/etc/bashrc`)
---
## 유틸리티 스크립트
......
# pty_centos
# ptyUtils
Elasticsearch, MySQL, AI API 등 다양한 서비스를 다루는 CLI 도구 모음입니다.
## 설치
### 원격 설치 (권장)
### 사용자 설치 (권장)
신규 서버에서 다음 명령어 하나로 설치할 수 있습니다:
홈 디렉토리에 설치합니다. root 권한이 필요하지 않습니다.
```bash
curl -sSL https://gitlab.platyhouse.com/platyhouse/centos/-/raw/master/ptyInstall.sh | bash
......@@ -18,14 +18,42 @@ curl -sSL https://gitlab.platyhouse.com/platyhouse/centos/-/raw/master/ptyInstal
wget -qO- https://gitlab.platyhouse.com/platyhouse/centos/-/raw/master/ptyInstall.sh | bash
```
- **설치 경로:** `~/ptyUtils.git`
- **설정 파일:** `~/.bashrc` (macOS: `~/.zshrc`)
### 전역 설치
시스템 전역에 설치합니다. root 권한이 필요하며, 모든 사용자가 사용할 수 있습니다.
```bash
curl -sSL https://gitlab.platyhouse.com/platyhouse/centos/-/raw/master/ptyInstallGlobal.sh | bash
```
또는:
```bash
wget -qO- https://gitlab.platyhouse.com/platyhouse/centos/-/raw/master/ptyInstallGlobal.sh | bash
```
- **설치 경로:** `/var/lib/ptyUtils.git`
- **설정 파일:** `/etc/bashrc`
### 수동 설치
```bash
git clone https://gitlab.platyhouse.com/platyhouse/centos.git /var/lib/pty_centos.git
cd /var/lib/pty_centos.git
# 사용자 설치
git clone https://gitlab.platyhouse.com/platyhouse/centos.git ~/ptyUtils.git
cd ~/ptyUtils.git
chmod +x pty*
./ptySetBash
source ~/.bashrc
# 전역 설치 (root 필요)
sudo git clone https://gitlab.platyhouse.com/platyhouse/centos.git /var/lib/ptyUtils.git
cd /var/lib/ptyUtils.git
sudo chmod +x pty*
sudo ./ptySetBash --install-global
source /etc/bashrc
```
## 설정 파일
......@@ -124,7 +152,9 @@ apiUrl=http://localhost:11434
|---------|------|
| `ptyRun` | 스크립트 중복 실행 제어 + 로깅 |
| `ptyCronBuild` | 크론탭 자동 등록 |
| `ptySetBash` | Bash 환경 설정 |
| `ptySetBash` | Bash 환경 설정 (`--install-global` 옵션으로 /etc/bashrc 설정) |
| `ptyInstall.sh` | 사용자 설치 스크립트 (~/ptyUtils.git) |
| `ptyInstallGlobal.sh` | 전역 설치 스크립트 (/var/lib/ptyUtils.git) |
---
......
......@@ -19,10 +19,10 @@ require_once __DIR__ . '/ptyLibrary_PHP/mysql/ptyMysqlConfig.php';
$parsed = ptyCliOptionParser::parse($argv);
$positionalArgs = $parsed['positional'];
$options = $parsed['options'];
$mysqlSection = $options['mysql'] ?? 'default';
$mysqlSection = isset($options['mysql']) ? $options['mysql'] : 'default';
$verbose = isset($options['verbose']);
$outputDir = $options['output'] ?? '.';
$ignoreX = ($options['ignore-x'] ?? 'true') !== 'false'; // 기본값: true
$outputDir = isset($options['output']) ? $options['output'] : '.';
$ignoreX = (isset($options['ignore-x']) ? $options['ignore-x'] : 'true') !== 'false'; // 기본값: true
$dryRun = isset($options['dry-run']);
$useTgz = isset($options['tgz']);
......
......@@ -20,12 +20,12 @@ require_once __DIR__ . '/ptyLibrary_PHP/mysql/ptyMysqlConfig.php';
$parsed = ptyCliOptionParser::parse($argv);
$positionalArgs = $parsed['positional'];
$options = $parsed['options'];
$mysqlSection = $options['mysql'] ?? 'default';
$mysqlSection = isset($options['mysql']) ? $options['mysql'] : 'default';
$verbose = isset($options['verbose']);
$force = isset($options['force']);
$inputDir = $options['input'] ?? '.';
$targetDatabase = $options['db'] ?? null;
$targetTable = $options['table'] ?? null;
$inputDir = isset($options['input']) ? $options['input'] : '.';
$targetDatabase = isset($options['db']) ? $options['db'] : null;
$targetTable = isset($options['table']) ? $options['table'] : null;
// 도움말 또는 필수 인자 확인
if (empty($positionalArgs) || isset($options['help'])) {
......@@ -303,10 +303,10 @@ try {
}
// --db 옵션이 있으면 해당 DB로, 없으면 파일명에서 추출한 DB 사용
$dbName = $targetDatabase ?? $origDbName;
$dbName = $targetDatabase !== null ? $targetDatabase : $origDbName;
// --table 옵션이 있으면 해당 테이블로, 없으면 파일명에서 추출한 테이블 사용
$tableName = $targetTable ?? $origTableName;
$tableName = $targetTable !== null ? $targetTable : $origTableName;
$size = filesize($sqlFile);
$totalSize += $size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment