Fedora 27は起動時にrc.localを実行しません。

Fedora 27は起動時にrc.localを実行しません。

起動後、Shadowsocksサーバーが自動的に実行されるようにしたいのですが、このrc.localファイルを使用しましたが機能しません。

rc.local今は:

/usr/local/bin/ssserver -c /etc/shadowsocks.json -d start
#!/bin/bash
exit 0
  • a+x権限を追加しました/etc/rc/d/rc.local
  • また、提案されているようにシンボリックリンクを変更しました/etc/rc.local -> /etc/rc.d/rc.local(デフォルト権限)。777ここ

ただし、起動時にコードはrc.localまだ実行されません。rc.localシステムの起動時にシステムが実行されていないことがわかりました。助けを借りてここ、問題をより詳しく診断できました。

/etc/systemd/system/rc-local.serviceファイルは次のとおりです(何も変更していません)。

[Unit]
Description=/etc/rc.d/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.d/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.d/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

- このファイルは大丈夫ですか?

これを行うと、systemctl enable rc-local次のエラーが発生します。

The unit files have no installation config (WantedBy, RequiredBy, Also, Alias
settings in the [Install] section, and DefaultInstance for template units).
This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's 
.wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
4) In case of template units, the unit is meant to be enabled with some
instance name specified.

rc.local私の場合、ファイルが単純すぎて原因が何であるかわかりません。

ベストアンサー1

rc.localが破損しています!

/usr/local/bin/ssserver -c /etc/shadowsocks.json -d start
#!/bin/bash
exit 0

しなければならない

#!/bin/bash
/usr/local/bin/ssserver -c /etc/shadowsocks.json -d start
exit 0

編集する:

あなたのシステムサービスrc.localに何が問題なのかわかりません。

ただし、Shadowsockを起動および停止できるように、別々のsystemdデバイスを作成します。たとえば、構成を再ロードしたい場合は、サーバーを維持する必要があるユーザー以外のユーザーは、Serveを再起動する必要があるターゲットを知ることができます。

Shadowsocksシステム単位ファイルの例:

[Unit]
Description=Shadowsocks proxy server

[Service]
User=www-shadow
Group=www-shadow
Type=simple
ExecStart=/usr/local/bin/ssserver -c /etc/shadowsocks/shadowsocks.json -a shadowsocks -v start
ExecStop=/usr/local/bin/ssserver -c /etc/shadowsocks/shadowsocks.json -a shadowsocks -v stop

[Install]
WantedBy=multi-user.target

これには、グループのメンバーであるwww-shadowエージェントを実行しているユーザーがあります。作業をきれいにwww-shadowするために、ディレクトリを作成し、JSONやその他のShadowsocks関連ファイルをディレクトリに配置することをお勧め/etcします。/etc/shadowsocks次のウェブサイトで上記のシステム単位ファイルに関する基本情報を入手しました。linode.comしかし、彼らはエージェントをrootとして実行しようとしています(baaaaaaaaaad)...デフォルトで8388ポートを使用していることを考えると、これが必要かどうか疑われます。そのユニットのユーザーとグループを作成しないと、www-shadowsystemdはサービスをスムーズに実行することに注意してくださいroot

私はShadowsocksの経験がなく(イカをプロキシとして使用し、SSHをソックスプロキシとして使用したことがあります;-)、参照する時間はありませんでしたが、デバイスファイルを少し見てから合理的に見えます。 (愚かなことを除いてroot)。

以前のバージョンとの互換性のために単位ファイルを使用することはrc.localあまり意味がありません。 IMHOあなたはExecStopを逃し、rc.localはShadowsocksであることを覚えておく必要があります...

この装置を修理するには()でrc.localなければなりません。誰も書き込み可能なデーモンスクリプトを望んでいません。これは別の問題かもしれません。 IMHO、systemdが常に合理的なわけではありませんが、世界中で書き込み可能なスクリプトを実行するかどうかは疑問です。755chmod 755 /etc/rc.d/rc.local

安全のためにls -l /etc/rc.d/rc.local質問に出力を投稿できますか?

編集2:

このような(愚かな私はいつもそこにいたし、私は気づかなかった)、ユニットファイルに次のディレクティブがありません[Install]

[Install]
WantedBy=multi-user.target

おすすめ記事