Posted
Filed under 개발/Linux
* Github Repository
https://github.com/go-gitea/gitea


* git 설치
[code]
$sudo apt install git
[/code]

* gitea 디렉토리에 바이너리 다운로드
[code]
$mkdir ~/gitea
$cd ~/gitea
$wget -O gitea https://dl.gitea.io/gitea/master/gitea-master-linux-arm-6
[/code]

* MySQL 셋업
[code]
$sudo mysql -u root
CREATE DATABASE gitea;
CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost';
FLUSH PRIVILEGES
^C
[/code]

* 서버실행
[code]
$cd ~/gitea
$chmod 755 gitea
$./gitea web
[/code]

* 접속 후 환경설정
데이터베이스 유형 : MySQL
호스트: 127.0.0.1:3306
Username: gitea
비밀번호: password
데이터베이스 이름: gitea
Charset: utf8
저장소 최상위 경로 : /home/pi/gitea/gitea-repositories
LFS Root Path : /home/pi/gitea/data/LFS
데몬 사용자 계정 : pi
도메인 : localhost
SSH 포트 :
HTTP 포트 : 3000
애플리케이션 URL : http://라즈베리파이IP:3000/
로그 경로 : /home/pi/gitea/log


* 서비스에 등록
[code]
$sudo nano /etc/systemd/system/gitea.service

[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target

[Service]
# Modify these two values ??and uncomment them if you have
# repos with lots of files and get to HTTP error 500 because of that
###
# LimitMEMLOCK=infinity
# LimitNOFILE=65535
RestartSec=2s
Type=simple
User=pi
Group=pi
WorkingDirectory=/home/pi/gitea
ExecStart=/home/pi/gitea/gitea web
Restart=always
Environment=USER=pi
HOME=/home/pi

[Install]
WantedBy=multi-user.target
[/code]

* 서비스 시작
[code]
sudo systemctl enable gitea.service
sudo systemctl start gitea.service
[/code]

* gitea nginx 설정
[code]
$sudo nano /etc/nginx/sites-available/git.qualitybits.net
server {
    listen 443 ssl;
    server_name 도메인;
    ssl_certificate     /etc/letsencrypt/live/도메인/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/도메인/privkey.pem;

    location / {
        client_max_body_size 364M;
        proxy_pass http://localhost:3000;
        proxy_connect_timeout 600;
        proxy_send_timeout 600;
        proxy_read_timeout 600;
        send_timeout 600;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

server {
    listen 80;
    server_name 도메인;
    return 301 https://$server_name$request_uri;
}
[/code]

* 심볼릭링크 작성
[code]
$sudo ln -s /etc/nginx/sites-available/도메인 /etc/nginx/sites-enabled/도메인
[/code]

* SSL 인증서 취득
[code]
$sudo systemctl stop nginx
$sudo certbot certonly --standalone -d 도메인
$sudo systemctl start nginx
[/code]


* 업데이트
[code]
$sudo systemctl stop gitea.service
$mv -f /home/pi/gitea/gitea /home/pi/gitea/gitea.old
$wget -O /home/pi/gitea/gitea https://dl.gitea.io/gitea/master/gitea-master-linux-arm-6
$chmod +x /home/pi/gitea/gitea
$sudo systemctl start gitea.service
[/code]


* 인증서 갱신
[code]
$ sudo systemctl stop nginx
$ sudo certbot renew
$ sudo systemctl start nginx
[/code]


* 데이터 백업
[code]
# login as your database user, for me it is root
$ su -

# navigate to your gitea folder
$ cd /home/USER/gitea

# run the dump command
$ ./gitea dump -V -t /media/USER/USB/
[/code]


* 데이터 복구
[code]
apt-get install gitea
unzip gitea-dump-1482906742.zip
cd gitea-dump-1482906742
mv custom/conf/app.ini /etc/gitea/conf/app.ini # or mv app.ini /etc/gitea/conf/app.ini
unzip gitea-repo.zip
mv gitea-repo/* /home/pi/gitea/gitea-repositories/
chown -R gitea:gitea /etc/gitea/conf/app.ini /home/pi/gitea/gitea-repositories/
mysql -u$USER -p$PASS $DATABASE <gitea-db.sql
# or  sqlite3 $DATABASE_PATH <gitea-db.sql
service gitea restart
[/code]
2020/03/15 18:54 2020/03/15 18:54