Ubuntu One. u1sdtool
Contingut
Referències i Introducció
- https://wiki.edubuntu.org/UbuntuOne/u1sdtool
- http://linuxprograms.wordpress.com/2010/11/01/u1sdtool-ubuntu-one-command-line-tutorial/
Avui en dia és habitual fer còpies de seguretat al núvol i compartir la informació. Per exemple, serveis al núvol que ofereixen força espai de disc al núvol de forma gratuïta:
- ownCloud: https://owncloud.com/
- Dropbox: https://www.dropbox.com/
- Ubuntu One: https://one.ubuntu.com/
- Copy: https://www.copy.com/home/
- Box: https://www.box.com/
Els avantatges bàsics que tenim són:
- sincronització: podem treballar amb els documents en diferents entorns (diferents ordinadors, tablet, mòbil), i ens assegurem de tenir sempre els documents sincronitzats i treballar sempre amb la última versió.
- compartició/sharing: podem compartir els nostres documents amb les persones o grups que elegim, fent fàcil el treball col.laboratiu.
Tots aquests serveis ens ofereixen una interfície web, i possiblement també una interfície d'escriptori si ens instal.lem l'aplicatiu d'escriptori corresponent. Ara bé, normalment disposen d'una eina de consola / dimoni per tal de poder executar comandes des de la consola.
Nosaltres, com a administradors de sistema, ens interessa aquesta aproximació per tal d'integrar la possibilitat de fer còpies de seguretat i sincronitzacions en els nostres scripts de manteniment.
En aquesta pràctica utilitzarem Ubuntu One amb l'eina u1sdtool. Per tant, es demana a l'alumne que disposi d'un compte de Ubuntu One. Si l'alumne no en disposa de cap i no té intenció d'obrir un compte que es posi en contacte amb el professor. També es pot explorar la possibilitat de fer la pràctica amb les altres eines com Dropbox o Copy.
Desenvolupament
$ man u1sdtool NAME u1sdtool - command line utility for controlling ubuntuone-syncdaemon SYNOPSYS u1sdtool [OPTION]... [ARGS] u1sdtool --wait u1sdtool --accept-share=SHARE_ID u1sdtool --reject-share=SHARE_ID u1sdtool --list-shares u1sdtool --refresh-shares u1sdtool --offer-share PATH USER SHARE_NAME ACCESS_LEVEL u1sdtool --list-shared u1sdtool --create-folder=PATH ... DESCRIPTION u1sdtool is a command line utility for controlling ubuntuone-syncdae‐ mon. It can be used to get information about the metadata of ubun‐ tuone-syncdaemon but also to create shares, accept or reject offered shares and to force a refresh on the list of shares. ...
Ara bé, el u1sdtool no és més que una comanda, en realitat el que importa és el dimoni:
$ ps aux | grep ubuntuone joan 2123 0.0 0.6 84564 24712 ? Sl 14:36 0:00 /usr/bin/python /usr/lib/ubuntuone-client/ubuntuone-syncdaemon
Per accedir a Uubuntu One i al dimoni tenim vàries opcions:
1. Aplicatiu d'escriptori: Control panel for Ubuntu One. L'aplicatiu d'escriptori està disponible des de:
$ ubuntuone-control-panel-qt
o bé Eines del Sistema > Paràmetres del sistema > Ubuntu One
2. Des de la web:
3. Amb la línia de comanda: u1sdtool.
Nosaltres ens ocuparem del u1sdtool, però pots fer servir els altres dos per monitoritzar.
Primer de tot ens hem de connectar
$ u1sdtool --start $ u1sdtool --connect $ u1sdtool --status State: QUEUE_MANAGER connection: With User With Network description: processing the commands pool is_connected: True is_error: False is_online: True queues: IDLE
Donada una carpeta que ja existeix en el nostre ordinador, podem crear una carpeta per a Uubuntu One (és a dir, podem crear un recurs compartit):
$ u1sdtool --create-folder=/home/joan/provaUO/ $ u1sdtool --list-folders Folder list: id=f3ecf1cb-3155-4988-96aa-3c6b4c8df4fc subscribed=False path=/home/joan/provaUO id=a3e59cad-f8fe-4441-ae96-75277a3a4ffd subscribed=False path=/home/joan/thumbnail id=966d2955-df59-4216-b0a8-2c145a72ace6 subscribed=False path=/home/joan/output
Per sincronitzar una carpeta o desincronitzar-la fem subscribe-folder (o --unsubscribe-folder)
Ara vull sincronitzar aquesta carpeta que he creat. (de fet no cal perquè per defecte quan crees una carpeta l'opció per defecte és de sincronitzar-la).
$ u1sdtool --subscribe-folder=FOLDER_ID: Enable synchronization for the FOLDER_ID specified. $ u1sdtool --subscribe-folder=f3ecf1cb-3155-4988-96aa-3c6b4c8df4fc
Com podem llegir a:
el fet de crear la carpeta ja l'estem sincronitzant, com queda definit en el fitxer de configuració /etc/xdg/ubuntuone/syncdaemon.conf (or ~/.config/ubuntuone/syncdaemon.conf to do it per user).
The act of selecting a folder to sync is called “subscribing” the folder, and is distinct from creating / deleting it (which is what is exposed via Nautilus). Meanwhile you can access the functionality via u1sdtool: to list all the folders syncdaemon knows about, enter u1sdtool --list-folders; then you use the folder ids listed there to enter the id in u1sdtool --subscribe-folder=folderid (or --unsubscribe). The default behavior is for syncdaemon to subscribe to folders automatically when they are created; you can change this by editing /etc/xdg/ubuntuone/syncdaemon.conf (or ~/.config/ubuntuone/syncdaemon.conf to do it per user) and add a line udf_autosubscribe = False to the [__main__] section.
Així doncs, si faig --unsubscribe-folder, la funcionalitat de sincronització automàtica desapareix.
- Exercici:
Busquem una foto per Internet, i la guardem en la carpeta que acabem de crear. Veiem en el Nautilus que quan fiquem la foto a la carpeta automàticament es sincronitza la foto en el núvol. Podem obtenir una URL pública d'aquest fitxer:
--publish-file=PATH: Publish the already synchronized file and get a public link: $ u1sdtool --publish-file=/home/joan/provaUO/kailash.jpg File is published at http://ubuntuone.com/0LcwU5j0cTIVLFUe1BDwVT
Podem obtenir més informació d'una carpeta:
$ u1sdtool --info=/home/joan/provaUO/ File: /home/joan/provaUO crc32: None generation: None info_created: 1392390790.55 info_is_partial: False info_node_id_assigned: 1392390790.55 is_dir: True local_hash: mdid: f1a4e658-b71f-4b5f-b379-a6bf5325bf6c node_id: 30fd0903-d9af-46f0-ad8a-725ddd21a92a path: /home/joan/provaUO server_hash: share_id: f3ecf1cb-3155-4988-96aa-3c6b4c8df4fc size: None stat: posix.stat_result(st_mode=16893, st_ino=5111904L, st_dev=2049L, st_nlink=2, st_uid=1000, st_gid=1000, st_size=4096L, st_atime=1392390758, st_mtime=1392390760, st_ctime=1392390760)
Per compartir una carpeta amb un altre usuari de Ubuntu One:
--offer-share: Share PATH to USER. --offer-share=PATH USER SHARE_NAME ACCESS_LEVEL: Offer a share to another user. PATH is a full path to the folder being shared USER is an E-Mail address of the user that is being offered this share SHARE_NAME is a name given to the shared folder (can be different from the actual folder name of PATH). ACCESS_LEVEL can be "Read" or "Modify" (please note that the first letter is capital).
$ u1sdtool --offer-share=/home/joan/provaUO/ joan_quintana@yahoo.com fotos_himalaya View
Per tal de què funcioni el sharing hem de ser un verified account:
How do I share files? (with other Ubuntu One users...) The command --offer-share is used to share a folder with other Ubuntu One users. So if you and me were working on a project, for instance, we could share a folder containing that project. You can run the following to see the list of 'shares' The sharing options are only available to verified accounts. First, go to https://login.ubuntu.com/+emails and make sure you have a verified email address. If you had to follow the verification process, then go to https://one.ubuntu.com/auth/logout/ and log in again. The quickest and easiest way to share a single file is to publish it: Open https://one.ubuntu.com/files Click the "More" link next to the photo you want to share Click the "Publish file" link Copy the URL and send it to your friend This URL will download the file for anyone who has the URL. You can disable it at any time by following steps 1-2 above and then click the "Stop publishing" link. If you want to share a folder, then you'll want to do that by: Open https://one.ubuntu.com/files Click the "More" link next to the folder you want to share Click the "Share folder" link and then enter your friend's email address Your friend will receive an email inviting him or her to sign-in or sign-up for Ubuntu One and then will have access to that folder.
Per tant, hem de comprovar que som un verified account.
Si ho volem fer en línia de comanda:
$ u1sdtool --offer-share=PATH USER SHARE_NAME ACCESS_LEVEL $ u1sdtool --offer-share=/home/joan/provaUO joan_quintana@yahoo.com provaUO View
però no acaba de funcionar, tot i que en la interfície gràfica aparentment sí que funciona. Si ho fem amb la interfície gràfica ens sortirà:
Shared with joan_quintana@yahoo.com to view/change files on Feb-24-2014 (waiting to be accepted) Stop sharing
Puc mirar quines carpetes tinc compartides:
$ u1sdtool --list-shared Shared list: id=6b436cd2-b540-4359-b28a-97da5aae8f15 name=provaUO accepted=False access_level=View to= path=/home/joan/provaUO
i quines carpetes comparteixo
$ u1sdtool --list-shares
Altra informació que podem obtenir:
- fitxers que s'estan pujant o descarregant, va bé quan s'estan actualitzant fitxers grossos
$ u1sdtool --current-transfers Current uploads: 0 Current downloads: 0
- Espai lliure en el nostre volum:
$ u1sdtool --free-space=VOLUME_ID
Ara bé, com saps quins és el teu VOLUME_ID? (per investigar... punt positiu)
Ubuntu One a Ubuntu Server
Ja que estem utilitzant Ubuntu One en línia de comanda, es pot instal.lar sobre un Ubuntu Server (sense cap interfície gràfica)? Sí:
Feina per l'alumne
Realitzaràs un bash script. Enunciat:
En la pràctica del Wordpress que actualment estàs fent (una pràctica posterior a aquesta) localitza la carpeta on fiques les imatges dels teus posts. Per ex,
/var/www/wordpress/wp-content/uploads/2014/02$ ls 1049-1050-papallona-gran.gif
Hauràs de crear una sincronització sobre la carpeta uploads/, és a dir, vols que aquesta carpeta estigui sincronitzada en el núvol de Ubuntu One.
L'objectiu és fer un bash script, que s'executi diàriament (cron), i que publiqui (--publish-file la url pública dels uploads del teu blog). La sortida serà un fitxer de text amb el format:
uploads/2014/02/1049-1050-papallona-gran.gif http://ubuntuone.com/0LcwU5j0cTIVLFUe1BDwVT uploads/2014/02/1049-1050-papallona-petita.jpg http://ubuntuone.com/45cwU5jgpTIVLF341BDwVQ ...
Al final de tot fica també l'espai lliure que tens en el núvol:
$ u1sdtool --free-space= Free space: 5346891842 bytes
(TBD: falta aconseguir esbrinar quin és el teu VOLUME_ID, punt positiu...)
Dropbox en línia de comanda
- http://www.dropboxwiki.com/tips-and-tricks/using-the-official-dropbox-command-line-interface-cli
- http://xmodulo.com/2013/09/access-dropbox-command-line-linux.html
closure of Ubuntu One file services
Ubuntu One file services Safata d'entrada Ubuntu One noreply@one.ubuntu.com Hi, We are writing to you to notify you that we will be shutting down the Ubuntu One file services, effective 1 June 2014. This email gives information about the closure and what you should expect during the shutdown process. As of today, it will no longer be possible to purchase storage or music from the Ubuntu One store. The Ubuntu One file services apps in the Ubuntu, Google, and Apple stores will be updated appropriately. As always, your content belongs to you. You can simply download your files onto your PC or an external hard drive. While the service will stop as of 1 June, you will have an additional two months (until 31 July 2014) to collect all of your content. After that date, all remaining content will be deleted. If you have an active annual subscription, the unused portion of your fees will be refunded. The refund amount will be calculated from today's announcement. We know you have come to rely on Ubuntu One, and we apologise for the inconvenience this closure may cause. We've always been inspired by the support, feedback and enthusiasm of our users and want to thank you for the support you've shown for Ubuntu One. We hope that you'll continue to support us as together we bring a revolutionary experience to new devices. The Ubuntu One team
Alternatives a Ubuntu One
Entrega
Recorda la normativa per entregar les pràctiques al Schoology: ASIX-M09-IAW#Normativa_d.27entrega_de_les_pr.C3.A0ctiques_al_Moodle.
Per demostrar que has fet allò que es pretén i que has arribat allà on es pretén, n'hi haurà prou en fer unes captures de pantalla. Recorda d'escriure en el fitxer LLEEIX-ME els dubtes, problemes, èxits i fracassos que t'has trobat.
creat per Joan Quintana Compte, febrer 2014