echo "要事先建立數據庫gitea@gitea password:gitea" systemctl stop firewalld echo "一、addUser" u=gitea g=$u groupadd $g useradd $u -g $g -s /bin/false mkdir /home/$u mkdir /home/$u/desktop chown -hR $u:$g /home/$u usermod -s /bin/bash $u usermod -d /home/$u $u echo "二、安裝gitea" yum -y install git #apt-get mkdir /www chmod 775 /www mkdir /www/$u #curl -o target/path/filename URL #-O original name giteaUrl="https://dl.gitea.io/gitea/1.11.4/gitea-1.11.4-linux-amd64" #curl -o /www/$u/gitea https://dl.gitea.io/gitea/1.4/gitea-1.4-linux-386 #curl -o /www/$u/gitea $giteaUrl yum -y install wget wget -O /www/$u/gitea $giteaUrl chmod +x /www/$u/gitea #五、修改所屬人和所屬組 chown -R $u:$g /www/$u chmod 755 -R /www/$u echo "三、添加服務" cat>/etc/systemd/system/gitea.service<<EOF [Unit] Description=Gitea (Git with a cup of tea) After=syslog.target After=network.target [Service] RestartSec=2s Type=simple User=gitea Group=gitea #WorkingDirectory=/www/$u/lib #Environment=USER=gitea HOME=/www/$u/git GITEA_WORK_DIR=/www/$u/lib ExecStart=/www/$u/gitea web --config /www/$u/custom/conf/app.ini Restart=always [Install] WantedBy=multi-user.target EOF #systemctl daemon-reload sudo systemctl enable gitea #sudo systemctl start gitea echo "四、安裝" echo "非root用戶端口,只能大於1024" echo "安裝時,LFS根目錄留空" echo 沒有則安裝完,把/www/$u/custom/conf/app.ini裏面LFS_START_SERVER=改成false echo "而後重啓動服務" echo "安裝頁面:http://localhost:3000" cd /www/$u #必須不然權限,但腳本里好像不能cd su $u -c /www/$u/gitea web echo "五、安裝完重啓動服務" echo "sudo systemctl restart gitea" sudo systemctl restart gitea #sudo systemctl start gitea