Я пытаюсь использовать сценарий ожидания в контейнере Arch Linux docker, но получаю сообщение об ошибке:
spawn protonvpn init
[ -- PROTONVPN-CLI INIT -- ]
Traceback (most recent call last):
File "/usr/sbin/protonvpn", line 8, in <module>
sys.exit(main())
File "/usr/lib/python3.8/site-packages/protonvpn_cli/cli.py", line 73, in main
cli()
File "/usr/lib/python3.8/site-packages/protonvpn_cli/cli.py", line 96, in cli
init_cli()
File "/usr/lib/python3.8/site-packages/protonvpn_cli/cli.py", line 212, in init_cli
print(textwrap.fill(line, width=term_width))
File "/usr/lib/python3.8/textwrap.py", line 391, in fill
return w.fill(text)
File "/usr/lib/python3.8/textwrap.py", line 363, in fill
return "\n".join(self.wrap(text))
File "/usr/lib/python3.8/textwrap.py", line 354, in wrap
return self._wrap_chunks(chunks)
File "/usr/lib/python3.8/textwrap.py", line 248, in _wrap_chunks
raise ValueError("invalid width %r (must be > 0)" % self.width)
ValueError: invalid width 0 (must be > 0)
send: spawn id exp6 not open
while executing
"send "$env(ID)\r""
(file "/sbin/protonvpnActivate.sh" line 5)
Но когда я запускаю его вручную в контейнере linux все идет хорошо.
[root@e2c097bb81ed /]# /usr/bin/expect /sbin/protonvpnActivate.sh
spawn protonvpn init
[ -- PROTONVPN-CLI INIT -- ]
ProtonVPN uses two different sets of credentials, one for the website and official apps where the username is most likely your e-mail, and one for
connecting to the VPN servers.
You can find the OpenVPN credentials at https://account.protonvpn.com/account.
--- Please make sure to use the OpenVPN credentials ---
Enter your ProtonVPN OpenVPN username:
Enter your ProtonVPN OpenVPN password:
Confirm your ProtonVPN OpenVPN password:
Please choose your ProtonVPN Plan
1) Free
2) Basic
3) Plus
4) Visionary
Your plan: 3
Choose the default OpenVPN protocol.
OpenVPN can act on two different protocols: UDP and TCP.
UDP is preferred for speed but might be blocked in some networks.
TCP is not as fast but a lot harder to block.
Input your preferred protocol. (Default: UDP)
1) UDP
2) TCP
Your choice: 1
You entered the following information:
Username: xxx
Password: xxxxxx
Tier: Plus
Default protocol: UDP
Is this information correct? [Y/n]: Y
Writing configuration to disk...
Done! Your account has been successfully initialized.
Вот сценарий запуска, который используется ожидаемой командой:
#!/usr/bin/expect
spawn protonvpn init
expect "username:"
send "$env(ID)\r"
expect "password:"
send "$env(PASSWORD)\r"
expect "password:"
send "$env(PASSWORD)\r"
expect "plan:"
send "3\r"
expect "choice:"
send "1\r"
expect "correct?"
send "Y\r"
expect eof
А вот docker -compose.yml:
version: "3.7"
services:
protonvpn:
image: protonvpn:archlinux_template
environment:
- ID=***
- PASSWORD=******
volumes:
- "/opt/protonvpn/entrypoint.sh:/sbin/entrypoint.sh:rw"
- "/opt/protonvpn/protonvpnActivate.sh:/sbin/protonvpnActivate.sh:rw"
entrypoint: ["/bin/bash", "/sbin/entrypoint.sh"]
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
stdin_open: true
privileged: true
restart: unless-stopped
In заранее, спасибо за всю помощь, которую вы можете оказать.