Svn 和git 同时使用

已经是git仓库情况

1、svn checkout

2、svn status 查看状态,会有许多删除冲突

3、使用revert命令恢复 svn revert ./* -R [或者单独文件 R递归]

4、再次查看状态,删除冲突消失

5、git pull ,git reset –hard 清除svn的更改,然后查看git 和svn状态是否正常,

6、修改,往两处提交就可以了

此过程可能需要多次gc cleanup

1 Svn checkout

2 git pull

3 换行符问题

4 git 修改为 autocrlf

5 Add 提示有些lf转换问题

6 再改为autocrlf false

7 再次add

Debian(树莓派)开机启动脚本设置

为了更好的理解启动脚本的设置,我们需要先了解下Debian系统中的运行级别。

  • 0 – 停机(千万不要把initdefault设置为0 )
  • 1 – 单用户模式(单用户模式,只允许root用户对系统进行维护。)
  • 2 – 多用户,但是没有NFS
  • 3 – 完全多用户模式(字符界面)
  • 4 – 基本不用
  • 5 – X11(图形界面)
  • 6 – 重新启动(千万不要把initdefault设置为6 )

查看当前系统的运行级别

runlevel

/etc/rcN.d目录

通常系统启动后先执行/etc/rcS.d/目录下的脚本,然后根据运行级别,执行对应/etc/rcN.d/目录下的脚本(N为系统运行级别)。

下面是/etc/rc5.d目录下的内容

lrwxrwxrwx 1 root root  24 Dec 30 15:56 K02gmediarenderer -> ../init.d/gmediarenderer lrwxrwxrwx 1 root root  16 Jan 24 23:52 K02mopidy -> ../init.d/mopidy lrwxrwxrwx 1 root root  18 Jan 24 23:55 K02upmpdcli -> ../init.d/upmpdcli -rw-r–r– 1 root root 677 Apr  7  2015 README lrwxrwxrwx 1 root root  18 Sep 24 21:21 S01bootlogs -> ../init.d/bootlogs lrwxrwxrwx 1 root root  16 Sep 24 22:33 S01dhcpcd -> ../init.d/dhcpcd lrwxrwxrwx 1 root root  17 Oct 21 13:27 S01hd-idle -> ../init.d/hd-idle lrwxrwxrwx 1 root root  17 Sep 24 21:33 S01ifplugd -> ../init.d/ifplugd lrwxrwxrwx 1 root root  14 Jan 14 14:37 S02dbus -> ../init.d/dbus lrwxrwxrwx 1 root root  21 Mar  3 16:04 S02ddns-dnspod -> ../init.d/ddns-dnspod . . . . . . . . . . . .

我们可以看到有K和S开头的文件,K代表关闭,S代表启动,后面紧跟的数字代表启动顺序,数字越大启动或关闭就越靠后。目录下的每一个文件都指向了/etc/init.d目录中的文件,开机启动脚本就是放在这个目录下的。

文件中代表启动顺序的数字是根据依赖关系自动设置的,在新版的update-rc.d命令中无法手动设置这个数字。查看是否可以手动设置参看man update-rc.d说明。

添加新的启动脚本

在/etc/init.d目录下新建一个文件,并添加执行权限sudo chmod a+x xxx_script。

#!/bin/sh ### BEGIN INIT INFO # Provides:          ddns-dnspod # Required-Start:    $local_fs $remote_fs $network $syslog # Required-Stop:     $local_fs $remote_fs $network $syslog # Default-Start:     2 3 4 5 # Default-Stop:      0 1 6 # Short-Description: starts the ddns-dnspod service # Description:       starts the ddns-dnspod service ### END INIT INFO   case “$1” in start) echo “start ddns-dnspod” sudo /home/pi/work/projects/dnspod_ddns/dnspod_ddns.py -d start ;; stop) sudo /home/pi/work/projects/dnspod_ddns/dnspod_ddns.py -d stop ;; restart) sudo /home/pi/work/projects/dnspod_ddns/dnspod_ddns.py -d restart ;; *) echo “Usage: $0 (start|stop)” ;; esac exit 0

上面是一个ddns的开机启动脚本。我们需要在启动脚本的注释中写明启动依赖和在那些运行级别启动。具体的依赖名写法可以参考这里

当在/etc/init.d目录下添加新的启动脚本后,我们最好先进行下测试,执行下各种选项确保正常运行。

/etc/init.d/xxx_script start /etc/init.d/xxx_script stop 以git用户运行,后台运行 su – git -c nohup -c /home/git/gitea-1.7-linux-arm-7 web &   

update-rc.d命令

在/etc/init.d目录下添加启动脚本后,我们需要使用update-rc.d命令设置脚本开机启动。

update-rc.d xxx_script defaults

执行完上面命令后,查看/etc/rcN.d目录中是否有指向xxx_script文件的启动和关闭文件。另外还会向/run/systemd/generator.late/目录添加一个service,这样我们就可以使用sudo service xxx_script start|stop命令来控制脚本运行。

update-rc.d其他参数用法

# 移除开机启动连接(/etc/rcN.d 目录下的文件) sudo update-rc.d xxx_script remove # 启用或者禁用开机启动 sudo update-rc.d xxx_script enable|disable

Apache2 https配置

一、修改配置文件

/etc/apache2/sites-available/default-ssl.conf

1、添加证书信息

      SSLEngine on

      #   A self-signed (snakeoil) certificate can be created by installing

      #   the ssl-cert package. See

      #   /usr/share/doc/apache2/README.Debian.gz for more info.

      #   If both key and certificate are stored in the same file, only the

      #   SSLCertificateFile directive is needed.

  #     SSLCertificateFile      /etc/ssl/certs/ssl-cert-snakeoil.pem

  #     SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

  SSLCertificateFile      /etc/letsencrypt/live/yourdomain.com/fullchain.pem

  SSLCertificateKeyFile /etc/letsencrypt/live/yourdomain.com/privkey.pem

二、运行命令a2enmod  ssl 开启SSL模块很重要 /关闭a2dismod ssl

三、运行命令a2ensite default-ssl.conf启用ssl站点很重要

四、重启Apache2或者 service apache2 reload

五、apachectl configtest   # 检查apache配置是否正确

Nginx 反向代理https配置

一、修改nginx配置

vi /etc/nginx/sites-available/default

server{

       listen 443 ssl;  #ssl不能少,否则报错

       server_name yourdomain.com;

        ssl_certificate /etc/letsencrypt/live/ yourdomain.com /fullchain.pem;

        ssl_certificate_key /etc/letsencrypt/live/ yourdomain.com/privkey.pem;

        ssl_session_timeout 5m;

        ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;

        ssl_ciphers “HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES”;

        ssl_prefer_server_ciphers on;

       location / {

          proxy_pass   https://127.0.0.1:4430;

       }

}

或者

server{

       listen 80;

           server_name  127.0.0.1 localhost  yourdomain.com ;

        #  rewrite ^(.*)$  https://$host$1 permanent;

       location / {

          proxy_pass   https://127.0.0.1:4430;

       }

}

二、注意

# wordpress 一直以为配置失败,其实是wordpress没有修改路径为https

三、刷新 systemctl reload nginx使配置生效

使用Let’s Encrypt 部署https

1、安装

官方安装方式

$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository universe
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install certbot python-certbot-nginx

2、生成证书

$ sudo certbot –nginx

注意:执行命令后按照提示输入参数,直接下一步,最后会有重要提示,包含证书存放位置,需要记住,用于配置nginx、apache、tomcat等

IMPORTANT NOTES:

 – Congratulations! Your certificate and chain have been saved at:

   /etc/letsencrypt/live/123.com/fullchain.pem

   Your key file has been saved at:

   /etc/letsencrypt/live/ 123.com /privkey.pem

   Your cert will expire on 2019-08-08. To obtain a new or tweaked

   version of this certificate in the future, simply run certbot again

   with the “certonly” option. To non-interactively renew *all* of

   your certificates, run “certbot renew”

 – If you like Certbot, please consider supporting our work by:

3、自动更新

最后一步,就是证书的自动续期了。Let’s Encrypt的证书,默认的有效期是90天,不过官方推荐每60天续期。到期之后,我们需要用命令来为证书续期,不过我们是懒人,这种体力活还是交给机器来完成比较合适。所以,我们可以用Linux的cron job来完成这类的任务,配置cron job,每两个月的第一天,执行下面的命令:
vi /etc/crontab

0 0 1 */2 * certbot renew –post-hook  “systemctl reload nginx ” –post-hook “systemctl reload apache2” 

注意在cron job里面需要用绝对路径

4、nginx配置参考 「Nginx 反向代理https配置」