使用mc-tool实现empathy的自动登录与处理密钥环问题

来源:互联网 发布:webshell查杀工具 编辑:程序博客网 时间:2024/05/22 01:39

项目中使用empathy来实现一个远程协助的功能,需要自动帮客户端登录empathy,为了处理这个问题,找到了mc-tool来设置帐号。

例如添加帐号:

mc-tool add gabble/jabber 10.1.82.165@10.1.122.173 string:account=10.1.82.165@10.1.122.173 string:password=qwer1234 bool:require-encryption=true bool:ignore-ssl-errors=true

查看帐号:

mc-tool list

使用mc-tool remove可以删除。
因此做了个脚本,实现系统启动时候,自动添加好empathy的帐号。但首次执行会报 选择新密钥环的密码
设置新密钥环密码
若点击ESC取消,则设置仍会出这个。若点击取消按钮或确定,倒是可以。
一开始以为.local/share/keyring/下设置Default密钥环,后来试了发现是还是不行。
最后才找到应该在路径.config/mate/keyring/下设置,即OK了

附带脚本如下:

#!/bin/sh# Jabber服务器地址(ip地址或域名)server=10.1.122.173# 账户ID(为方便处理,id名称请使用字母和数字,不要包含任何其它字符和符号)id=10.1.82.165jid=${id}@${server}# 账户密码jid_pw=10.1.82.165cat >/usr/local/bin/do_jid_action.sh <<FOE#!/bin/shkeyring_init() {    # 预置一个不加密的缺省keyring,从而避免用户交互    [ ! -d ~/.config/mate/keyrings ] && mkdir -p ~/.config/mate/keyrings && chmod 700 ~/.config/mate/keyrings    cat > ~/.config/mate/keyrings/Default_keyring.keyring << EOF[keyring]display-name=Default keyringctime=\$(date +%s)mtime=0lock-on-idle=falselock-after=falseEOF    echo "Default_keyring" > ~/.config/mate/keyrings/default    chmod 600 ~/.config/mate/keyrings/Default_keyring.keyring    chmod 600 ~/.config/mate/keyrings/default}jid_add() {    # 检查要创建的账户是否已经存在,如存在则删除    account_id=$(echo ${jid}|sed 's/\./_2e/g'|sed 's/\@/_40/g')    for i in \$(mc-tool list |grep \${account_id});    do        mc-tool remove \$i    done    # 创建账户    account=\$(mc-tool add gabble/jabber ${jid} string:account=${jid} string:password=${jid_pw} bool:require-encryption=true bool:ignore-ssl-errors=true)    echo account=${account}    # set Icon=im-jabber    mc-tool icon \${account} im-jabber    # set Enabled=true    mc-tool enable \${account}}if [ ! -f ~/.jid_init_done ];then    [ -s ~/.config/mate/keyrings/default ] || keyring_init    jid_add    [ "$?" -eq 0 ] && touch ~/.jid_init_donefiFOEchmod a+x /usr/local/bin/do_jid_action.sh# 增加自启动服务,用户登录时建立账户#grep "/usr/local/bin/do_jid_action.sh" /etc/bashrc#[ "$?" -ne 0 ] && echo "/usr/local/bin/do_jid_action.sh" >> /etc/bashrcif [ ! -f /etc/xdg/autostart/xdg-jid-init.desktop ];then    cat > /etc/xdg/autostart/xdg-jid-init.desktop << EOF[Desktop Entry]Type=ApplicationName=JID INITExec=/usr/local/bin/do_jid_action.shOnlyShowIn=GNOME;MATE;EOFfi

参考:
empathy
https://wiki.gnome.org/action/show/Apps/Empathy?action=show&redirect=Empathy
mc-tool
http://telepathy.freedesktop.org/wiki/Mission_Control/
Telepathy Developer’s Manual
http://telepathy.freedesktop.org/doc/book/index.html
Components
http://telepathy.freedesktop.org/wiki/Components/

0 0
原创粉丝点击