Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
centos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
platyhouse
centos
Commits
8b00b120
Commit
8b00b120
authored
Oct 15, 2025
by
platyhouse
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bash, zshrc 설정 통합, ptySetBash 추가
parent
b35dff70
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
318 additions
and
83 deletions
+318
-83
pty
pty
+2
-83
ptySetBash
ptySetBash
+216
-0
pty_archive_account_db.php
pty_archive_account_db.php
+100
-0
No files found.
pty
View file @
8b00b120
...
@@ -153,89 +153,8 @@ EOF
...
@@ -153,89 +153,8 @@ EOF
# 3. /etc/bashrc 설정
# 3. /etc/bashrc 설정
#######################################
#######################################
setup_bashrc
()
{
setup_bashrc
()
{
echo
-e
"
${
CYAN
}
[3/11]
${
NC
}
/etc/bashrc 설정 추가"
SCRIPT_DIR
=
"
$(
cd
"
$(
dirname
"
$0
"
)
"
&&
pwd
)
"
echo
-e
"
${
YELLOW
}
/etc/bashrc에 커스텀 설정을 추가하시겠습니까? (y/N):
${
NC
}
\c
"
bash
$SCRIPT_DIR
/ptySetBash
read
-n
1
-r
REPLY_BASHRC
echo
if
[[
$REPLY_BASHRC
=
~ ^[Yy]
$
]]
;
then
# 백업 생성
cp
/etc/bashrc /etc/bashrc.backup.
$(
date
+%Y%m%d_%H%M%S
)
# bashrc에 추가할 내용
cat
>>
/etc/bashrc
<<
'
EOF
'
#######################################
# pty_setup_centos.sh 에 의한 /etc/bashrc 추가 시작
#######################################
# 프롬프트 색상 설정
export PS1='
\[\0
33[01;32m
\]\u
@
\h\[\0
33[00m
\]
:
\[\0
33[01;34m
\]\w\[\0
33[00m
\]\$
'
# 히스토리 설정
export HISTSIZE=10000
export HISTFILESIZE=20000
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
# 기본 에디터 설정
export EDITOR=vi
# 유용한 alias
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias grep='grep --color=auto'
alias df='df -h'
alias du='du -h'
# git 관련 명령
alias gs="git status"
alias gd="git diff --word-diff"
alias ga="git add"
alias gb="git branch"
alias gc="git checkout"
alias gl="git log --date=format:'%Y-%m-%d %H:%M:%S'"
# 2025-09-25 깃 add, commit 처리. gac "커밋내용"
gac() {
git add -A
git commit -m "
$*
"
}
## git show 에서 파일명 깨짐 방지
git config --global core.quotepath false
## git 자소 분리시 해결
git config --global core.precomposeunicode true
## git color
git config --global color.ui true
git config --global color.status.changed "#ff0000 normal bold"
git config --global color.status.untracked "#dd99dd normal bold"
git config --global color.status.header "#ffffff normal bold"
## user 설정
git config --global user.name "KwangHee Yoo"
git config --global user.email "cpueblo@platyhouse.com"
## git 인증 정보 저장
git config credential.helper store
# . 명령.sh 실행을 위함
PATH=
$PATH
:.
# pty_centos.git 의 실행을 위함
PATH=
$PATH
:/var/lib/pty_centos.git
#######################################
EOF
echo
-e
"
${
GREEN
}
✓
${
NC
}
/etc/bashrc 설정이 완료되었습니다."
else
echo
-e
"
${
YELLOW
}
⊘
${
NC
}
/etc/bashrc 설정을 건너뜁니다."
fi
echo
""
}
}
#######################################
#######################################
...
...
ptySetBash
0 → 100755
View file @
8b00b120
#!/bin/bash
#######################################
# CentOS 초기 설정 스크립트
# 사용법: ./setup_centos.sh
#######################################
set
-e
# 에러 발생 시 스크립트 중단
# 색상 정의
CYAN
=
'\033[0;36m'
BLUE
=
'\033[1;94m'
# 밝은 파란색
PURPLE
=
'\033[0;35m'
GREEN
=
'\033[0;32m'
YELLOW
=
'\033[1;33m'
RED
=
'\033[0;31m'
NC
=
'\033[0m'
# No Color
# 로고 출력
echo
-e
"
${
CYAN
}
"
# OS 감지
OS_TYPE
=
$(
uname
-s
)
if
[[
"
$OS_TYPE
"
==
"Darwin"
]]
;
then
# macOS
RC_FILE
=
"
$HOME
/.zshrc"
RC_NAME
=
"~/.zshrc"
SHELL_TYPE
=
"zsh"
elif
[[
"
$OS_TYPE
"
==
"Linux"
]]
;
then
# Linux (CentOS)
RC_FILE
=
"
$HOME
/.bashrc"
RC_NAME
=
"~/.bashrc"
SHELL_TYPE
=
"bash"
else
echo
-e
"
${
RED
}
지원하지 않는 OS입니다:
$OS_TYPE
${
NC
}
"
exit
1
fi
echo
-e
"
$RC_NAME
설정 추가"
echo
-e
"
${
YELLOW
}
$RC_NAME
에 커스텀 설정을 추가하시겠습니까? (y/N):
${
NC
}
\c
"
read
-n
1
-r
REPLY_BASHRC
echo
# n 또는 다른 입력인 경우 먼저 처리하고 종료
if
[[
!
$REPLY_BASHRC
=
~ ^[Yy]
$
]]
;
then
echo
-e
"
${
YELLOW
}
⊘
${
NC
}
설정을 건너뜁니다."
echo
""
exit
0
fi
# y인 경우 설정 진행
# 현재 스크립트 실행 경로 저장
SCRIPT_DIR
=
"
$(
cd
"
$(
dirname
"
$0
"
)
"
&&
pwd
)
"
# 맥 설정
if
[[
"
$OS_TYPE
"
==
"Darwin"
]]
;
then
# 백업 생성
cp
~/.zshrc ~/.zshrc.backup.
$(
date
+%Y%m%d_%H%M%S
)
# ~/.zshrc 추가할 내용
cat
>>
~/.zshrc
<<
'
EOF
'
#######################################
# pty-bash 에 의한 ~/.zshrc 추가 시작
#######################################
# ls, ll 정의
COLOR_DEF=
$'
\e
[0m'
COLOR_USR=
$'
\e
[38;5;243m'
COLOR_DIR=
$'
\e
[38;5;197m'
COLOR_GIT=
$'
\e
[38;5;39m'
export TERM=xterm-color
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export GREP_OPTIONS='--color=auto'
# 프롬프트 정의
function parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^
\*
\(
.*
\)
/[
\1
]/p'
}
setopt PROMPT_SUBST
#export PROMPT='
${
COLOR_USR
}
%n
${
COLOR_DIR
}
%~
${
COLOR_GIT
}
$(
parse_git_branch
)
${
COLOR_DEF
}
$
'
export PROMPT='%n %~
$(
parse_git_branch
)
$
'
# 유용한 alias
alias ll="ls -alv"
alias ls='ls -GFh'
# git 관련 명령
alias gs="git status"
alias gd="git diff --word-diff"
alias ga="git add"
alias gb="git branch"
alias gc="git checkout"
alias gl="git log --date=format:'%Y-%m-%d %H:%M:%S'"
# 2025-09-25 깃 add, commit 처리. gac "커밋내용"
gac() {
git add -A
git commit -m "
$*
"
}
## git show 에서 파일명 깨짐 방지
git config --global core.quotepath false
## git 자소 분리시 해결
git config --global core.precomposeunicode true
## git color
git config --global color.ui true
git config --global color.status.changed "#ff0000 normal bold"
git config --global color.status.untracked "#dd99dd normal bold"
git config --global color.status.header "#ffffff normal bold"
## user 설정
git config --global user.name "KwangHee Yoo"
git config --global user.email "cpueblo@platyhouse.com"
## git 인증 정보 저장
# git config credential.helper store
# . 명령.sh 실행을 위함
PATH=
$PATH
:.
#######################################
EOF
# 스크립트 실행 경로를 PATH 에 추가
echo
""
>>
~/.zshrc
echo
"# 스크립트 실행 경로 추가"
>>
~/.zshrc
echo
"PATH=
\$
PATH:
$SCRIPT_DIR
"
>>
~/.zshrc
# centos 에 설정
elif
[[
"
$OS_TYPE
"
==
"Linux"
]]
;
then
# 백업 생성
cp
~/.bashrc ~/.bashrc.backup.
$(
date
+%Y%m%d_%H%M%S
)
# ~/.bashrc 추가할 내용
cat
>>
~/.bashrc
<<
'
EOF
'
#######################################
# pty-bash 에 의한 ~/.bashrc 추가 시작
#######################################
# 프롬프트 색상 설정
export PS1='
\[\0
33[01;32m
\]\u
@
\h\[\0
33[00m
\]
:
\[\0
33[01;34m
\]\w\[\0
33[00m
\]\$
'
# 히스토리 설정
export HISTSIZE=10000
export HISTFILESIZE=20000
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
# 기본 에디터 설정
export EDITOR=vi
# 유용한 alias
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias grep='grep --color=auto'
alias df='df -h'
alias du='du -h'
# git 관련 명령
alias gs="git status"
alias gd="git diff --word-diff"
alias ga="git add"
alias gb="git branch"
alias gc="git checkout"
alias gl="git log --date=format:'%Y-%m-%d %H:%M:%S'"
# 2025-09-25 깃 add, commit 처리. gac "커밋내용"
gac() {
git add -A
git commit -m "
$*
"
}
## git show 에서 파일명 깨짐 방지
git config --global core.quotepath false
## git 자소 분리시 해결
git config --global core.precomposeunicode true
## git color
git config --global color.ui true
git config --global color.status.changed "#ff0000 normal bold"
git config --global color.status.untracked "#dd99dd normal bold"
git config --global color.status.header "#ffffff normal bold"
## user 설정
git config --global user.name "KwangHee Yoo"
git config --global user.email "cpueblo@platyhouse.com"
## git 인증 정보 저장
# git config credential.helper store
# . 명령.sh 실행을 위함
PATH=
$PATH
:.
#######################################
EOF
# 스크립트 실행 경로를 PATH 에 추가
echo
""
>>
~/.bashrc
echo
"# 스크립트 실행 경로 추가"
>>
~/.bashrc
echo
"PATH=
\$
PATH:
$SCRIPT_DIR
"
>>
~/.bashrc
fi
echo
-e
"
${
GREEN
}
✓
${
NC
}
설정이 완료되었습니다."
echo
""
pty_archive_account_db.php
0 → 100644
View file @
8b00b120
<?php
error_reporting
(
E_STRICT
|
E_ALL
);
if
(
$argv
[
1
]
==
""
)
die
(
"php archive_server.php
\"
서버명
\"
\"
DB명
\"
\"
DB아이디
\"
,
\"
DB암호
\"
"
);
$dbHost
=
$argv
[
1
];
$dbName
=
$argv
[
2
];
$dbUserId
=
$argv
[
3
];
$dbPassword
=
$argv
[
4
];
// print_r(get_defined_vars());
system
(
"clear"
);
echo
"=========================================
\n
"
;
say
(
"Starting archive
$dbName
in
$dbHost
\n
"
);
echo
"=========================================
\n
"
;
archive
(
$dbHost
,
$dbName
,
$dbUserId
,
$dbPassword
);
// moveFile($STORYSHARE, $srcIp, $srcDbUserId, $srcDbPassword);
say2
(
"finished"
);
function
archive
(
$dbHost
,
$dbName
,
$dbUserId
,
$dbPassword
)
{
$date
=
date
(
"Ymd_His"
);
$fileName
=
"
{
$dbName
}
_${date}.sql"
;
$path
=
"/root/pty"
;
// www 와 db 압축
if
(
true
)
{
echo
"=========================================
\n
"
;
say
(
"Archiving www and db in
$dbHost
\n
"
);
echo
"=========================================
\n
"
;
cmd
(
"ssh
$dbHost
-l root 'rm /root/
{
$dbName
}
_db.tgz;'"
);
// www 와 db 의 tgz 압축
// cmd("ssh $dbHost -l root 'cd /root; tar czf {$dbName}_www.tgz www'");
$cmd
=
"mysqldump -h 127.0.0.1 -u
$dbUserId
-p
$dbName
--password='
$dbPassword
' --default-character-set=utf8mb4_unicode_ci --complete-insert --routines --triggers --single-transaction > /root/
{
$dbName
}
_db.sql"
;
$cmd
=
str_replace
(
"'"
,
"'
\"
'
\"
'"
,
$cmd
);
cmd
(
"ssh
$dbHost
-l root '
$cmd
'"
);
cmd
(
"ssh
$dbHost
-l root 'cd /root/; tar czf
{
$dbName
}
_db.tgz
{
$dbName
}
_db.sql; rm /home/
{
$dbName
}
_db.sql;'"
);
}
}
function
moveFile
(
$accountName
,
$srcHost
,
$srcDbPassword
,
$dst
)
{
cmd
(
"ssh
$dst
-l root 'adduser
$accountName
;'"
);
cmd
(
"ssh
$dst
-l root 'mkdir /home/
$accountName
;'"
);
{
echo
"=========================================
\n
"
;
say
(
"Downloading src's www and db to dst (with local)
\n
"
);
echo
"=========================================
\n
"
;
@
mkdir
(
"tmp"
);
cmd
(
"sftp root@
{
$srcHost
}
:/home/
{
$accountName
}
/
{
$accountName
}
_db.tgz tmp/
{
$accountName
}
_db.tgz"
);
cmd
(
"sftp root@
{
$srcHost
}
:/home/
{
$accountName
}
/
{
$accountName
}
_www.tgz tmp/
{
$accountName
}
_www.tgz"
);
cmd
(
"ssh
$srcHost
-l root 'rm /home/
$accountName
/
{
$accountName
}
_www.tgz; rm /home/
$accountName
/
{
$accountName
}
_db.tgz;'"
);
/*
echo "=========================================\n";
say("Uploading www and db to $dst (with local)\n");
echo "=========================================\n";
cmd("sftp root@{$dst}:/home/{$STORYSHARE} <<< $'put tmp/{$STORYSHARE}_db.tgz'");
cmd("sftp root@{$dst}:/home/{$STORYSHARE} <<< $'put tmp/{$STORYSHARE}_www.tgz'");
*/
}
/*
// 대상에 압축 풀기
if (true) {
echo "=========================================\n";
say("Extracting www and db in $dst\n");
echo "=========================================\n";
cmd("ssh $dst -l root 'cd /home/{$STORYSHARE}/; tar xzf /home/{$STORYSHARE}/{$STORYSHARE}_db.tgz'");
cmd("ssh $dst -l root 'cd /home/{$STORYSHARE}/; tar xzf /home/{$STORYSHARE}/{$STORYSHARE}_www.tgz'");
}
*/
}
function
say
(
$msg
)
{
echo
$msg
;
// system("say --voice Samantha $msg");
}
function
say2
(
$msg
)
{
echo
$msg
;
system
(
"say --voice Samantha
$msg
"
);
}
function
cmd
(
$cmd
)
{
echo
"#
{
$cmd
}
\n
"
;
system
(
$cmd
);
}
?>
platyhouse
@platyhouse
mentioned in commit
8587004b
·
Dec 16, 2025
mentioned in commit
8587004b
mentioned in commit 8587004bfbebb2ceff13804bc1eea04727f6a285
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment