вторник, 18 марта 2014 г.

Copy.com init.d script for console sync

I'm testing new cloud storage Copy.com. This service has console client for Linux and it is great for backup stuff. If you register with this link, you will get 20Gigs of space.

Now. Copy.com provides only linux binaries with no init.d script. We can create our own:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          CopyAgent
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: CopyAgent
# Description:       CopyConsole (Copy cloud storage by Barracuda) service
### END INIT INFO

RUN_AS="root"
HOME=`grep $RUN_AS /etc/passwd | cut -d":" -f6`
CC="$HOME/copy/x86/CopyConsole"

start() {
   echo "Starting CopyConsole..."
       if [ -x $CC ]; then
           start-stop-daemon -b -o -c $RUN_AS -S -u $RUN_AS -x $CC -- -daemon
       fi
}

stop() {
   echo "Stopping CopyConsole..."
       if [ -x $CC ]; then
           start-stop-daemon -o -c $RUN_AS -K -u $RUN_AS -x $CC
       fi
}

status() {
       dbpid=`pgrep -u $RUN_AS CopyConsole`
       if [ -z $dbpid ] ; then
           echo "CopyConsole for user $RUN_AS: not running."
       else
           echo "CopyConsole for user $RUN_AS: running (pid $dbpid)"
       fi
}

case "$1" in

   start)
       start
       ;;
   stop)
       stop
       ;;
   restart|reload|force-reload)
       stop
       start
       ;;
   status)
       status
       ;;
   *)
       echo "Usage: /etc/init.d/copy.com {start|stop|reload|force-reload|restart|status}"
       exit 1

esac

exit 0

Do now forget to setup proper user to run from and check your installation path in CC property.

четверг, 6 марта 2014 г.

Upload .ipa to TestFlight from console

Add this code, filled out with your own TestFlight info, after the export DEVELOP_DIR line:
# testflight stuff
API_TOKEN=<YOUR API TOKEN>
TEAM_TOKEN=<YOUR TEAM TOKEN>

Add this to the end of the existing script:
#
# Send to TestFlight
#
/usr/bin/curl "http://testflightapp.com/api/builds.json" \
  -F file=@"${IPA_DIR}/${PROJECT}.ipa" \
  -F dsym=@"${IPA_DIR}/${PROJECT}.dSYM.zip" \
  -F api_token="${API_TOKEN}" \
  -F team_token="${TEAM_TOKEN}" \
  -F notes="Build ${BUILD_NUMBER} uploaded automatically from Xcode. Tested by Chuck Norris" \
  -F notify=True \
  -F distribution_lists='all'
 
echo "Successfully sent to TestFlight"

Source from: Beginning Automated Testing With Xcode Part 2/2

понедельник, 3 марта 2014 г.

Mac OS X: Create user, Create group, Add user to group, Change password from terminal

List existing group IDs in numerical order to choose an unused one for new group :-
$ dscl . -list /Groups PrimaryGroupID | awk '{print $2}' | sort -n
Create the new group 'newgroup' and assign it an ID :-
$ sudo dscl . -create /Groups/newgroup
$ sudo dscl . -create /Groups/newgroup PrimaryGroupID 1000
View the new group :-
$ dscl . -read /Groups/newgroup
AppleMetaNodeLocation: /Local/Default
GeneratedUID: 423AF02C-F053-41E0-ABCD-33127EF9A9CA
PrimaryGroupID: 1000
RecordName: newgroup
RecordType: dsRecTypeStandard:Groups
List existing user IDs in numerical order to choose an unused one for new user :-
$ dscl . -list /Users UniqueID | awk '{print $2}' | sort -n
Create the new user 'newuser' and assign various attributes :-
$ sudo dscl . -create /Users/newuser
$ sudo dscl . -create /Users/newuser UserShell /bin/bash
$ sudo dscl . -create /Users/newuser RealName "New User"
$ sudo dscl . -create /Users/newuser UniqueID "1000"
$ sudo dscl . -create /Users/newuser PrimaryGroupID 1000
View the new user :-
$ dscl . -read /Users/newuser
AppleMetaNodeLocation: /Local/Default
GeneratedUID: 47D6D841-C7F1-4962-9F7E-167E8BFC3A91
PrimaryGroupID: 1000
RealName:
 Application
RecordName: newuser
RecordType: dsRecTypeStandard:Users
UniqueID: 1000
UserShell: /usr/bash 
Add user to existing group :-
$ sudo dscl . -append /Groups/newgroup GroupMembership newuser
Change user password :-
$ sudo dscl . passwd /Users/newuser PASSWORD

Mac OS X: Enabling vnc remote management from console

If you have only ssh access, you can enable vnc server from shell, just run this:

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -restart -agent -privs -all -allowAccessFor -allUsers -clientopts -setvncpw -vncpw 123pass -setvnclegacy -vnclegacy yes
this command will enable vnc with password 123pass