Created
September 21, 2022 05:52
-
-
Save christian-oudard/3c26d90651b7eb142008267d289e966a to your computer and use it in GitHub Desktop.
Automate running pCloud from the command line with 1password and expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/bash | |
# Account information. | |
OP_EMAIL=<email> | |
OP_MOUNTPOINT=/home/<username>/pCloudDrive | |
OP_USER_ID=<user-id> # Gotten from `op account list`. | |
# Stop server. | |
if [[ $1 == 'stop' ]]; then | |
expect -f - >/dev/null <<END_EXPECT | |
spawn pcloudcc --commands_only | |
expect "pCloud console client v.2.0.1\r | |
Supported commands are:\r | |
startcrypto <crypto pass>, stopcrypto, finalize, q, quit\r | |
> " | |
send -- "finalize\r" | |
expect eof | |
END_EXPECT | |
exit 0 | |
fi | |
# Get passwords. | |
op whoami >/dev/null 2>&1 | |
if [[ $? == 1 ]]; then | |
eval $(op signin --account $OP_USER_ID) | |
export "OP_SESSION_$OP_USER_ID" | |
fi | |
PASSWORD=$(op item get pcloud --fields label="password") | |
CRYPTO_PASS=$(op item get pcloud --fields label="crypto pass") | |
# Start server. | |
expect -f - >/dev/null <<END_EXPECT | |
spawn pcloudcc --daemonize --username=$OP_EMAIL --mountpoint $OP_MOUNTPOINT --password --crypto | |
expect "pCloud console client v.2.0.1\r | |
Please, enter password\r | |
" | |
send -- "$PASSWORD\r" | |
expect "Enter crypto password.\r | |
Please, enter password\r | |
" | |
send -- "$CRYPTO_PASS\r" | |
expect eof | |
END_EXPECT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
but sorry what is 1password, a package to download ?